client/polyfill: add .querySelector to NodeList
This commit is contained in:
parent
dfb2e3d027
commit
009e13c6d8
1 changed files with 13 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue