Skip to content

Commit 41af046

Browse files
committed
Merge pull request marcj#67 from lukaszzdanikowski/master
Support for multi queries, eg. [min-width="1px"][max-width="2px"]
2 parents c16cdc9 + 8916139 commit 41af046

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/ElementQueries.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,19 @@
179179
}
180180
}
181181

182-
var regex = /,?([^,\n]*)\[[\s\t]*(min|max)-(width|height)[\s\t]*[~$\^]?=[\s\t]*"([^"]*)"[\s\t]*]([^\n\s\{]*)/mgi;
182+
var regex = /,?([^,\n]*?)\[[\s\t]*?(min|max)-(width|height)[\s\t]*?[~$\^]?=[\s\t]*?"([^"]*?)"[\s\t]*?]([^\n\s\{]*?)/mgi;
183183

184184
/**
185185
* @param {String} css
186186
*/
187187
function extractQuery(css) {
188188
var match;
189+
var smatch;
189190
css = css.replace(/'/g, '"');
190191
while (null !== (match = regex.exec(css))) {
191192
if (5 < match.length) {
192-
queueQuery(match[1] || match[5], match[2], match[3], match[4]);
193+
smatch = match[1] || match[5] || smatch;
194+
queueQuery(smatch, match[2], match[3], match[4]);
193195
}
194196
}
195197
}

src/ResizeSensor.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@
125125
addEvent(expand, 'scroll', onScroll);
126126
addEvent(shrink, 'scroll', onScroll);
127127
}
128-
129-
if ("[object Array]" === Object.prototype.toString.call(element)
128+
129+
var elementType = Object.prototype.toString.call(element);
130+
if ('[object Array]' === elementType
131+
|| ('[object NodeList]' === elementTyle)
132+
|| ('[object HTMLCollection]' === elementTyle)
130133
|| ('undefined' !== typeof jQuery && element instanceof jQuery) //jquery
131134
|| ('undefined' !== typeof Elements && element instanceof Elements) //mootools
132135
) {
@@ -151,4 +154,4 @@
151154
}
152155
};
153156

154-
})();
157+
})();

0 commit comments

Comments
 (0)