From: Morgan Harris Date: Tue, 23 Nov 2021 01:43:02 +0000 (+1100) Subject: Fix broken parents() function X-Git-Tag: 3.1.2~2^2~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ed0989b26ea7c5954d1ebeac89960bc9ec49aedf;p=svg.js.git Fix broken parents() function --- 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