client/polyfill: add .querySelector to NodeList
This commit is contained in:
parent
dfb2e3d027
commit
009e13c6d8
@ -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…
x
Reference in New Issue
Block a user