diff options
author | wout <wout@impinc.co.uk> | 2014-06-21 18:25:29 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-06-21 18:25:29 +0200 |
commit | 19b6fd4338246d1fd9ca4806e57c7aebcec63826 (patch) | |
tree | 3dd1d207de9f586f7e4d4cd36917e347ab022a9e /src/selector.js | |
parent | bb0e6be2da0cea98c5303871c0be055f5f70d7a9 (diff) | |
download | svg.js-19b6fd4338246d1fd9ca4806e57c7aebcec63826.tar.gz svg.js-19b6fd4338246d1fd9ca4806e57c7aebcec63826.zip |
Removed all structural references
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 |