Permalink
Browse files

fix handling of DOM nodes as selector expressions

  • Loading branch information...
amccollum committed Jul 11, 2012
1 parent 906ddbc commit 34c42955d50f420b0e60072467290b02fcaf197c
Showing with 27 additions and 27 deletions.
  1. +8 −8 lib/sel.js
  2. +1 −1 package.json
  3. +9 −9 src/sel/sel.coffee
  4. +9 −9 src/sel/select.coffee
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "sel",
- "version": "0.7.3",
+ "version": "0.7.4",
"description": "Small, fast CSS4 selector library",
"keywords": ["ender", "css", "css4", "selector engine", "jquery", "sizzle"],
"author": "Andrew McCollum <amccollum@gmail.com>",
View
@@ -765,10 +765,10 @@
if not roots
return [document]
- else if typeof roots == 'string'
+ else if typeof roots is 'string'
return select(roots, [document])
- else if typeof roots == 'object' and isFinite(roots.length)
+ else if typeof roots is 'object' and isFinite(roots.length)
if roots.sort
# Array -- make sure it's sorted in document order
roots.sort(elCmp)
@@ -788,7 +788,13 @@
if not selector
return []
- else if typeof selector == 'object' and isFinite(selector.length)
+ else if selector.nodeType == 1
+ if not _roots or roots.some((root) -> contains(root, selector))
+ return [selector]
+ else
+ return []
+
+ else if typeof selector is 'object' and isFinite(selector.length)
return selector
else if tagPattern.test(selector)
@@ -800,12 +806,6 @@
else if selector in [document, 'document']
return [document]
- else if selector.nodeType == 1
- if not _roots or roots.some((root) -> contains(root, selector))
- return [selector]
- else
- return []
-
else
return select(selector, roots, matchRoots)
matchesSelector = html.matchesSelector or html.mozMatchesSelector or html.webkitMatchesSelector or html.msMatchesSelector
View
@@ -55,10 +55,10 @@
if not roots
return [document]
- else if typeof roots == 'string'
+ else if typeof roots is 'string'
return select(roots, [document])
- else if typeof roots == 'object' and isFinite(roots.length)
+ else if typeof roots is 'object' and isFinite(roots.length)
if roots.sort
# Array -- make sure it's sorted in document order
roots.sort(elCmp)
@@ -78,7 +78,13 @@
if not selector
return []
- else if typeof selector == 'object' and isFinite(selector.length)
+ else if selector.nodeType == 1
+ if not _roots or roots.some((root) -> contains(root, selector))
+ return [selector]
+ else
+ return []
+
+ else if typeof selector is 'object' and isFinite(selector.length)
return selector
else if tagPattern.test(selector)
@@ -90,11 +96,5 @@
else if selector in [document, 'document']
return [document]
- else if selector.nodeType == 1
- if not _roots or roots.some((root) -> contains(root, selector))
- return [selector]
- else
- return []
-
else
return select(selector, roots, matchRoots)

0 comments on commit 34c4295

Please sign in to comment.