diff options
author | Morgan Harris <gormster@me.com> | 2021-11-23 12:43:02 +1100 |
---|---|---|
committer | Morgan Harris <gormster@me.com> | 2021-11-23 12:43:02 +1100 |
commit | ed0989b26ea7c5954d1ebeac89960bc9ec49aedf (patch) | |
tree | 170879dd1f7a99cf03ccfdaf3debc53ec08b5365 /src/elements/Element.js | |
parent | b01c7ee0bc70b1221aa887be355634e1b4e0dd06 (diff) | |
download | svg.js-ed0989b26ea7c5954d1ebeac89960bc9ec49aedf.tar.gz svg.js-ed0989b26ea7c5954d1ebeac89960bc9ec49aedf.zip |
Fix broken parents() function
Diffstat (limited to 'src/elements/Element.js')
-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 |