Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@dperini authored
Showing with 0 additions and 38 deletions.
  1. +0 −38 src/nwmatcher.js
View
38 src/nwmatcher.js
@@ -221,14 +221,6 @@
NATIVE_TRAVERSAL_API =
'nextElementSibling' in root && 'previousElementSibling' in root,
- // select Matches Selector API to use if available
- NATIVE_MATCHES_SELECTOR =
- isNative(root, 'matchesSelector') ? 'matchesSelector' :
- isNative(root, 'oMatchesSelector') ? 'oMatchesSelector' :
- isNative(root, 'msMatchesSelector') ? 'msMatchesSelector' :
- isNative(root, 'mozMatchesSelector') ? 'mozMatchesSelector' :
- isNative(root, 'webkitMatchesSelector') ? 'webkitMatchesSelector' : null,
-
// BUGGY_XXXXX true if method is feature tested and has known bugs
// detect buggy gEBID
BUGGY_GEBID = NATIVE_GEBID ?
@@ -291,17 +283,6 @@
})() :
true,
- // detect matchesSelector correctly throw errors
- BUGGY_PSEUDOS = NATIVE_MATCHES_SELECTOR ?
- (function() {
- try {
- root[NATIVE_MATCHES_SELECTOR](':buggy');
- return true;
- } catch(e) { }
- return false;
- })() :
- true,
-
// detect Safari bug with selected option elements
BUGGY_SELECTED =
(function() {
@@ -383,9 +364,6 @@
// matches class selectors
RE_CLASS = new RegExp('(?:\\[[\\x20\\t\\n\\r\\f]*class\\b|\\.' + identifier + ')'),
- // matches pseudo-classes
- RE_PSEUDOS = new RegExp(':[-\\w]+'),
-
// matches simple id, tag & class selectors
RE_SIMPLE_SELECTOR = new RegExp(
!(BUGGY_GEBTN && BUGGY_GEBCN) ? !OPERA ?
@@ -1310,22 +1288,6 @@
}
} else parts = lastPartsMatch;
- // use matchesSelector API if available
- if (!XML_DOCUMENT && Config.USE_QSAPI && element[NATIVE_MATCHES_SELECTOR] &&
- !(BUGGY_QUIRKS_QSAPI && RE_CLASS.test(selector)) &&
- !(BUGGY_PSEUDOS && RE_PSEUDOS.test(selector)) &&
- !RE_BUGGY_QSAPI.test(selector)) {
- try {
- if (element[NATIVE_MATCHES_SELECTOR](selector)) {
- if (typeof callback == 'function') {
- callback(element);
- }
- return true;
- }
- return false;
- } catch(e) { }
- }
-
// compile matcher resolver if necessary
if (!matchResolvers[selector] || matchContexts[selector] !== from) {
matchResolvers[selector] = compile(isSingleMatch ? [selector] : parts, '', false);
Please sign in to comment.
Something went wrong with that request. Please try again.