diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2015-10-25 22:50:52 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2015-10-25 22:50:52 +0100 |
commit | f72c867e7e3da9d8939ab67afaddee0755678ba4 (patch) | |
tree | a2a0eb636ef9543334f2d7cfb6cec9ac0cce4622 /src/element.js | |
parent | 78e492ca461ccba1ca57eb2362be02280ef232ac (diff) | |
download | svg.js-f72c867e7e3da9d8939ab67afaddee0755678ba4.tar.gz svg.js-f72c867e7e3da9d8939ab67afaddee0755678ba4.zip |
added support for css selectors with the `parent()` method
Diffstat (limited to 'src/element.js')
-rw-r--r-- | src/element.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/element.js b/src/element.js index 01ab8b0..180fbfd 100644 --- a/src/element.js +++ b/src/element.js @@ -161,16 +161,16 @@ SVG.Element = SVG.invent({ // get parent element var parent = SVG.adopt(this.node.parentNode) - // if a specific type is given, find a parent with that class + // if a specific type or selector is given, find a parent with that class if (type) - while (!(parent instanceof type) && parent.node.parentNode instanceof SVGElement) + while (parent.node.parentNode instanceof SVGElement && !(typeof type === 'string' ? matches(parent.node, type) : parent instanceof type)) parent = SVG.adopt(parent.node.parentNode) return parent } } // Get parent document - , doc: function(type) { + , doc: function() { return this instanceof SVG.Doc ? this : this.parent(SVG.Doc) } // Returns the svg node to call native svg methods on it |