diff options
Diffstat (limited to 'src/selector.js')
-rw-r--r-- | src/selector.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/selector.js b/src/selector.js index 905e9f9..82aca37 100644 --- a/src/selector.js +++ b/src/selector.js @@ -1,5 +1,20 @@ // Method for getting an element by id SVG.get = function(id) { var node = document.getElementById(idFromReference(id) || id) - if (node) return node.instance -}
\ No newline at end of file + if (node) return SVG.adopt(node) +} + +// Select elements by query string +SVG.select = function(query, parent) { + return SVG.utils.map((parent || document).querySelectorAll(query), function(node) { + return SVG.adopt(node) + }) +} + +SVG.extend(SVG.Parent, { + // Scoped select method + select: function(query) { + return SVG.select(query, this.node) + } + +})
\ No newline at end of file |