From 009e13c6d8afcb82f8290c64cd3f46fde141afda Mon Sep 17 00:00:00 2001 From: rr- Date: Wed, 8 Jun 2016 22:37:59 +0200 Subject: [PATCH] client/polyfill: add .querySelector to NodeList --- client/js/util/polyfill.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/client/js/util/polyfill.js b/client/js/util/polyfill.js index 606d29d..51252c2 100644 --- a/client/js/util/polyfill.js +++ b/client/js/util/polyfill.js @@ -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) {