diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-12 13:59:07 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-12 13:59:07 +0100 |
commit | 334d9c73c2f74679a93b1d7b3e39b614f6444faa (patch) | |
tree | 75e7da40f8a1af67854816f1aa65b199b0733387 /src | |
parent | b9f5c216c6eb75f3a00c6b121da5a72885286fa0 (diff) | |
download | svg.js-334d9c73c2f74679a93b1d7b3e39b614f6444faa.tar.gz svg.js-334d9c73c2f74679a93b1d7b3e39b614f6444faa.zip |
reworked parents so that it is useful now, changelog
Diffstat (limited to 'src')
-rw-r--r-- | src/elements/Element.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/elements/Element.js b/src/elements/Element.js index 03b5f07..3b96bf4 100644 --- a/src/elements/Element.js +++ b/src/elements/Element.js @@ -1,7 +1,9 @@ import { getClass, makeInstance, register, root } from '../utils/adopter.js' +import { globals } from '../utils/window.js' import { proportionalSize } from '../utils/utils.js' import { reference } from '../modules/core/regex.js' import Dom from './Dom.js' +import List from '../types/List.js' import SVGNumber from '../types/SVGNumber.js' const Doc = getClass(root) @@ -75,16 +77,18 @@ export default class Element extends Dom { } // return array of all ancestors of given type up to the root svg - parents (type) { - let parents = [] + parents (until = globals.document) { + until = makeInstance(until) + let parents = new List() let parent = this - do { - parent = parent.parent(type) - if (!parent || parent instanceof getClass('HtmlNode')) break - + while ( + (parent = parent.parent()) && + parent.node !== until.node && + parent.node !== globals.document + ) { parents.push(parent) - } while (parent.parent) + } return parents } |