summaryrefslogtreecommitdiffstats
path: root/src/selector.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-06-21 18:25:29 +0200
committerwout <wout@impinc.co.uk>2014-06-21 18:25:29 +0200
commit19b6fd4338246d1fd9ca4806e57c7aebcec63826 (patch)
tree3dd1d207de9f586f7e4d4cd36917e347ab022a9e /src/selector.js
parentbb0e6be2da0cea98c5303871c0be055f5f70d7a9 (diff)
downloadsvg.js-19b6fd4338246d1fd9ca4806e57c7aebcec63826.tar.gz
svg.js-19b6fd4338246d1fd9ca4806e57c7aebcec63826.zip
Removed all structural references
Diffstat (limited to 'src/selector.js')
-rw-r--r--src/selector.js19
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