diff options
-rw-r--r-- | src/elements/Element.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/elements/Element.js b/src/elements/Element.js index f39f777..a1e7236 100644 --- a/src/elements/Element.js +++ b/src/elements/Element.js @@ -87,7 +87,13 @@ export default class Element extends Dom { // return array of all ancestors of given type up to the root svg parents (until = this.root()) { - until = makeInstance(until) + let selector = null + if (typeof until === 'string') { + selector = until + until = this.root() + } else { + until = makeInstance(until) + } const parents = new List() let parent = this @@ -101,6 +107,9 @@ export default class Element extends Dom { if (parent.node === until.node) { break } + if (selector && parent.matches(selector)) { + break + } } return parents |