Permalink
Browse files

Only element nodes have a getAttribute method

  • Loading branch information...
1 parent a783610 commit fcc5448f52c81207b4c5702a27a84e166ccf181b @fgnass committed Feb 8, 2012
Showing with 10 additions and 9 deletions.
  1. +10 −9 lib/select.js
View
@@ -85,15 +85,16 @@ var selectors = {
op = operators[op];
return function(el) {
var attr;
- if (key == 'for')
- attr = el.htmlFor;
- else if (key == 'class')
- attr = el.className;
- else if (key == 'href')
- attr = el.getAttribute('href', 2);
- else
- attr = key in el ? el[key] : el.getAttribute(key);
-
+ if (el.nodeType == 1) {
+ if (key == 'for')
+ attr = el.htmlFor;
+ else if (key == 'class')
+ attr = el.className;
+ else if (key == 'href')
+ attr = el.getAttribute('href', 2);
+ else
+ attr = key in el ? el[key] : el.getAttribute(key);
+ }
return attr != null && op(attr + '', val);
};
},

0 comments on commit fcc5448

Please sign in to comment.