Skip to content
This repository
Browse code

improved speed of 'match()' method by avoiding native 'matchesSelecto…

…r()' and related checks, fixes issue #40 (alpha123)
  • Loading branch information...
commit 10a48ac54c3673c125c540447bb74c75cd1a9ed4 1 parent 73704c8
Diego Perini authored

Showing 1 changed file with 0 additions and 38 deletions. Show diff stats Hide diff stats

  1. +0 38 src/nwmatcher.js
38 src/nwmatcher.js
@@ -221,14 +221,6 @@
221 221 NATIVE_TRAVERSAL_API =
222 222 'nextElementSibling' in root && 'previousElementSibling' in root,
223 223
224   - // select Matches Selector API to use if available
225   - NATIVE_MATCHES_SELECTOR =
226   - isNative(root, 'matchesSelector') ? 'matchesSelector' :
227   - isNative(root, 'oMatchesSelector') ? 'oMatchesSelector' :
228   - isNative(root, 'msMatchesSelector') ? 'msMatchesSelector' :
229   - isNative(root, 'mozMatchesSelector') ? 'mozMatchesSelector' :
230   - isNative(root, 'webkitMatchesSelector') ? 'webkitMatchesSelector' : null,
231   -
232 224 // BUGGY_XXXXX true if method is feature tested and has known bugs
233 225 // detect buggy gEBID
234 226 BUGGY_GEBID = NATIVE_GEBID ?
@@ -291,17 +283,6 @@
291 283 })() :
292 284 true,
293 285
294   - // detect matchesSelector correctly throw errors
295   - BUGGY_PSEUDOS = NATIVE_MATCHES_SELECTOR ?
296   - (function() {
297   - try {
298   - root[NATIVE_MATCHES_SELECTOR](':buggy');
299   - return true;
300   - } catch(e) { }
301   - return false;
302   - })() :
303   - true,
304   -
305 286 // detect Safari bug with selected option elements
306 287 BUGGY_SELECTED =
307 288 (function() {
@@ -383,9 +364,6 @@
383 364 // matches class selectors
384 365 RE_CLASS = new RegExp('(?:\\[[\\x20\\t\\n\\r\\f]*class\\b|\\.' + identifier + ')'),
385 366
386   - // matches pseudo-classes
387   - RE_PSEUDOS = new RegExp(':[-\\w]+'),
388   -
389 367 // matches simple id, tag & class selectors
390 368 RE_SIMPLE_SELECTOR = new RegExp(
391 369 !(BUGGY_GEBTN && BUGGY_GEBCN) ? !OPERA ?
@@ -1310,22 +1288,6 @@
1310 1288 }
1311 1289 } else parts = lastPartsMatch;
1312 1290
1313   - // use matchesSelector API if available
1314   - if (!XML_DOCUMENT && Config.USE_QSAPI && element[NATIVE_MATCHES_SELECTOR] &&
1315   - !(BUGGY_QUIRKS_QSAPI && RE_CLASS.test(selector)) &&
1316   - !(BUGGY_PSEUDOS && RE_PSEUDOS.test(selector)) &&
1317   - !RE_BUGGY_QSAPI.test(selector)) {
1318   - try {
1319   - if (element[NATIVE_MATCHES_SELECTOR](selector)) {
1320   - if (typeof callback == 'function') {
1321   - callback(element);
1322   - }
1323   - return true;
1324   - }
1325   - return false;
1326   - } catch(e) { }
1327   - }
1328   -
1329 1291 // compile matcher resolver if necessary
1330 1292 if (!matchResolvers[selector] || matchContexts[selector] !== from) {
1331 1293 matchResolvers[selector] = compile(isSingleMatch ? [selector] : parts, '', false);

0 comments on commit 10a48ac

Please sign in to comment.
Something went wrong with that request. Please try again.