From 97b7e6b770392cd070034955c68f2733e9324212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A3ukasz=20Zdanikowski?= Date: Wed, 30 Sep 2015 15:02:30 +0200 Subject: [PATCH 1/2] Add support for multi queries, eg. [min-width="1px"][max-width="2px"] --- src/ElementQueries.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ElementQueries.js b/src/ElementQueries.js index 2e4b566..6e7c357 100755 --- a/src/ElementQueries.js +++ b/src/ElementQueries.js @@ -179,17 +179,19 @@ } } - var regex = /,?([^,\n]*)\[[\s\t]*(min|max)-(width|height)[\s\t]*[~$\^]?=[\s\t]*"([^"]*)"[\s\t]*]([^\n\s\{]*)/mgi; + var regex = /,?([^,\n]*?)\[[\s\t]*?(min|max)-(width|height)[\s\t]*?[~$\^]?=[\s\t]*?"([^"]*?)"[\s\t]*?]([^\n\s\{]*?)/mgi; /** * @param {String} css */ function extractQuery(css) { var match; + var smatch; css = css.replace(/'/g, '"'); while (null !== (match = regex.exec(css))) { if (5 < match.length) { - queueQuery(match[1] || match[5], match[2], match[3], match[4]); + smatch = match[1] || match[5] || smatch; + queueQuery(smatch, match[2], match[3], match[4]); } } } From 5127e931ca16a2300d605f39546c9325c3023bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz?= Date: Thu, 1 Oct 2015 11:45:12 +0200 Subject: [PATCH 2/2] Fix for proper handling of native node lists Proper handling for NodeList and HTMLCollection objects --- src/ResizeSensor.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ResizeSensor.js b/src/ResizeSensor.js index 3d0d599..65315d2 100755 --- a/src/ResizeSensor.js +++ b/src/ResizeSensor.js @@ -125,8 +125,11 @@ addEvent(expand, 'scroll', onScroll); addEvent(shrink, 'scroll', onScroll); } - - if ("[object Array]" === Object.prototype.toString.call(element) + + var elementType = Object.prototype.toString.call(element); + if ('[object Array]' === elementType + || ('[object NodeList]' === elementTyle) + || ('[object HTMLCollection]' === elementTyle) || ('undefined' !== typeof jQuery && element instanceof jQuery) //jquery || ('undefined' !== typeof Elements && element instanceof Elements) //mootools ) { @@ -151,4 +154,4 @@ } }; -})(); \ No newline at end of file +})();