diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/elements/Element.js | 6 | ||||
-rw-r--r-- | src/elements/Image.js | 4 | ||||
-rw-r--r-- | src/elements/Svg.js | 8 | ||||
-rw-r--r-- | src/elements/TextPath.js | 2 | ||||
-rw-r--r-- | src/modules/optional/transform.js | 6 |
5 files changed, 13 insertions, 13 deletions
diff --git a/src/elements/Element.js b/src/elements/Element.js index 1f208c5..91aa3e0 100644 --- a/src/elements/Element.js +++ b/src/elements/Element.js @@ -52,13 +52,13 @@ export default class Element extends Dom { // Get defs defs () { - return this.doc().defs() + return this.root().defs() } // Get parent document - doc () { + root () { let p = this.parent(Svg) - return p && p.doc() + return p && p.root() } getEventHolder () { diff --git a/src/elements/Image.js b/src/elements/Image.js index bf2de0e..8f27470 100644 --- a/src/elements/Image.js +++ b/src/elements/Image.js @@ -52,12 +52,12 @@ registerAttrHook(function (attr, val, _this) { // convert image fill and stroke to patterns if (attr === 'fill' || attr === 'stroke') { if (isImage.test(val)) { - val = _this.doc().defs().image(val) + val = _this.root().defs().image(val) } } if (val instanceof Image) { - val = _this.doc().defs().pattern(0, 0, (pattern) => { + val = _this.root().defs().pattern(0, 0, (pattern) => { pattern.add(val) }) } diff --git a/src/elements/Svg.js b/src/elements/Svg.js index e634c6a..6172454 100644 --- a/src/elements/Svg.js +++ b/src/elements/Svg.js @@ -24,14 +24,14 @@ export default class Svg extends Container { // Check if this is a root svg // If not, call docs from this element - doc () { + root () { if (this.isRoot()) return this - return super.doc() + return super.root() } // Add namespaces namespace () { - if (!this.isRoot()) return this.doc().namespace() + if (!this.isRoot()) return this.root().namespace() return this .attr({ xmlns: ns, version: '1.1' }) .attr('xmlns:xlink', xlink, xmlns) @@ -40,7 +40,7 @@ export default class Svg extends Container { // Creates and returns defs element defs () { - if (!this.isRoot()) return this.doc().defs() + if (!this.isRoot()) return this.root().defs() return adopt(this.node.getElementsByTagName('defs')[0]) || this.put(new Defs()) diff --git a/src/elements/TextPath.js b/src/elements/TextPath.js index 324d768..91c48ae 100644 --- a/src/elements/TextPath.js +++ b/src/elements/TextPath.js @@ -51,7 +51,7 @@ registerMethods({ // if track is a path, reuse it if (!(track instanceof Path)) { // create path element - track = this.doc().defs().path(track) + track = this.root().defs().path(track) } // link textPath to path and add content diff --git a/src/modules/optional/transform.js b/src/modules/optional/transform.js index 7535fdc..b8f4c74 100644 --- a/src/modules/optional/transform.js +++ b/src/modules/optional/transform.js @@ -44,8 +44,8 @@ export function toParent (parent) { } // same as above with parent equals root-svg -export function toDoc () { - return this.toParent(this.doc()) +export function toRoot () { + return this.toParent(this.root()) } // Add transformations @@ -68,5 +68,5 @@ export function transform (o, relative) { } registerMethods('Element', { - untransform, matrixify, toParent, toDoc, transform + untransform, matrixify, toParent, toRoot, transform }) |