client/polyfill: add .querySelector to NodeList

This commit is contained in:
rr- 2016-06-08 22:37:59 +02:00
parent dfb2e3d027
commit 009e13c6d8

View file

@ -3,6 +3,19 @@
// fix iterating over NodeList in Chrome and Opera
NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
NodeList.prototype.querySelector = function(...args) {
for (let node of this) {
if (node.nodeType === 3) {
continue;
}
const result = node.querySelector(...args);
if (result) {
return result;
}
}
return null;
}
// non standard
Node.prototype.prependChild = function(child) {
if (this.firstChild) {