diff options
Diffstat (limited to 'lib/html-paths.js')
| -rw-r--r-- | lib/html-paths.js | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/html-paths.js b/lib/html-paths.js index 1d3b1f4..9ecb6dd 100644 --- a/lib/html-paths.js +++ b/lib/html-paths.js @@ -20,10 +20,29 @@ function elements(elementStyles) { function element(tagName, attributes, options) { options = options || {}; - return { - tagName: tagName, - attributes: attributes || {}, - fresh: options.fresh - }; + return new Element(tagName, attributes, options); } +function Element(tagName, attributes, options) { + var tagNames = {}; + if (_.isArray(tagName)) { + tagName.forEach(function(tagName) { + tagNames[tagName] = true; + }); + tagName = tagName[0]; + } else { + tagNames[tagName] = true; + } + + this.tagName = tagName; + this.tagNames = tagNames; + this.attributes = attributes || {}; + this.fresh = options.fresh; +} + +Element.prototype.matchesElement = function(element) { + return this.tagNames[element.tagName]; +} + + + |
