Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only element nodes have a getAttribute method

  • Loading branch information...
commit fcc5448f52c81207b4c5702a27a84e166ccf181b 1 parent a783610
@fgnass authored
Showing with 10 additions and 9 deletions.
  1. +10 −9 lib/select.js
View
19 lib/select.js
@@ -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);
};
},
Please sign in to comment.
Something went wrong with that request. Please try again.