diff options
author | wout <wout@impinc.co.uk> | 2014-06-21 22:04:12 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-06-21 22:04:12 +0200 |
commit | 1953dbcdb44c6ae94e18501e8c1168e8fb8d71d8 (patch) | |
tree | df59a0db9cc0156ba64ebbc08f3cb5b670f71153 /src | |
parent | 0bb294ad9189797014b1e1bf55e41ca4b1ead19e (diff) | |
download | svg.js-1953dbcdb44c6ae94e18501e8c1168e8fb8d71d8.tar.gz svg.js-1953dbcdb44c6ae94e18501e8c1168e8fb8d71d8.zip |
Documented and added specs for new selector method
Diffstat (limited to 'src')
-rw-r--r-- | src/selector.js | 8 | ||||
-rwxr-xr-x | src/set.js | 10 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/selector.js b/src/selector.js index 82aca37..ec6298a 100644 --- a/src/selector.js +++ b/src/selector.js @@ -6,9 +6,11 @@ SVG.get = function(id) { // Select elements by query string SVG.select = function(query, parent) { - return SVG.utils.map((parent || document).querySelectorAll(query), function(node) { - return SVG.adopt(node) - }) + return new SVG.Set( + SVG.utils.map((parent || document).querySelectorAll(query), function(node) { + return SVG.adopt(node) + }) + ) } SVG.extend(SVG.Parent, { @@ -1,8 +1,8 @@ SVG.Set = SVG.invent({ // Initialize - create: function() { - /* set initial state */ - this.clear() + create: function(members) { + // Set initial state + Array.isArray(members) ?this.members = members : this.clear() } // Add class methods @@ -91,8 +91,8 @@ SVG.Set = SVG.invent({ // Add parent method , construct: { // Create a new set - set: function() { - return new SVG.Set + set: function(members) { + return new SVG.Set(members) } } }) |