summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--dist/svg.js32
-rw-r--r--spec/spec/doc.js2
-rw-r--r--spec/spec/element.js16
-rw-r--r--src/elements/Element.js6
-rw-r--r--src/elements/Image.js4
-rw-r--r--src/elements/Svg.js8
-rw-r--r--src/elements/TextPath.js2
-rw-r--r--src/modules/optional/transform.js6
9 files changed, 39 insertions, 38 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 87c12f8..9eeba9b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -84,6 +84,7 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http:
- `fill()` and `stroke()` return the fill and stroke attribute when called as getter (#789)
- `parents()` now gives back all parents until the passed one or document
- `Image` callback passes normal `load` event instead of custom object (#931)
+- renamed `Doc` to `Svg` and `doc()` to `root` (and `toDoc()/toRoot()`) (#932)
### Fixed
- fixed a bug in clipping and masking where empty nodes persists after removal -> __TODO!__
diff --git a/dist/svg.js b/dist/svg.js
index 876caf0..7b311f9 100644
--- a/dist/svg.js
+++ b/dist/svg.js
@@ -6,7 +6,7 @@
* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
-* BUILT: Mon Nov 19 2018 19:49:34 GMT+0100 (GMT+01:00)
+* BUILT: Mon Nov 19 2018 21:40:15 GMT+0100 (GMT+01:00)
*/;
var SVG = (function () {
'use strict';
@@ -2637,14 +2637,14 @@ var SVG = (function () {
}, {
key: "defs",
value: function defs() {
- return this.doc().defs();
+ return this.root().defs();
} // Get parent document
}, {
- key: "doc",
- value: function doc() {
+ key: "root",
+ value: function root$$1() {
var p = this.parent(Svg);
- return p && p.doc();
+ return p && p.root();
}
}, {
key: "getEventHolder",
@@ -2964,8 +2964,8 @@ var SVG = (function () {
return this;
} // same as above with parent equals root-svg
- function toDoc() {
- return this.toParent(this.doc());
+ function toRoot() {
+ return this.toParent(this.root());
} // Add transformations
function transform(o, relative) {
@@ -2991,7 +2991,7 @@ var SVG = (function () {
untransform: untransform,
matrixify: matrixify,
toParent: toParent,
- toDoc: toDoc,
+ toRoot: toRoot,
transform: transform
});
@@ -3472,12 +3472,12 @@ var SVG = (function () {
// convert image fill and stroke to patterns
if (attr$$1 === 'fill' || attr$$1 === '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, function (pattern) {
+ val = _this.root().defs().pattern(0, 0, function (pattern) {
pattern.add(val);
});
}
@@ -6235,16 +6235,16 @@ var SVG = (function () {
// If not, call docs from this element
}, {
- key: "doc",
- value: function doc() {
+ key: "root",
+ value: function root$$1() {
if (this.isRoot()) return this;
- return _get(_getPrototypeOf(Svg.prototype), "doc", this).call(this);
+ return _get(_getPrototypeOf(Svg.prototype), "root", this).call(this);
} // Add namespaces
}, {
key: "namespace",
value: function namespace() {
- if (!this.isRoot()) return this.doc().namespace();
+ if (!this.isRoot()) return this.root().namespace();
return this.attr({
xmlns: ns,
version: '1.1'
@@ -6254,7 +6254,7 @@ var SVG = (function () {
}, {
key: "defs",
value: function 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());
} // custom parent method
@@ -6938,7 +6938,7 @@ var SVG = (function () {
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/spec/spec/doc.js b/spec/spec/doc.js
index a875906..19dda04 100644
--- a/spec/spec/doc.js
+++ b/spec/spec/doc.js
@@ -17,7 +17,7 @@ describe('Svg', function() {
})
it('returns itself as Svg when root', function() {
- expect(draw.doc()).toBe(draw)
+ expect(draw.root()).toBe(draw)
})
it('has a defs element when root', function() {
diff --git a/spec/spec/element.js b/spec/spec/element.js
index 96d512b..4845f03 100644
--- a/spec/spec/element.js
+++ b/spec/spec/element.js
@@ -435,7 +435,7 @@ describe('Element', function() {
})
})
- describe('toDoc()', function() {
+ describe('toRoot()', function() {
var nested, g1, g2, rect
beforeEach(function() {
@@ -447,9 +447,9 @@ describe('Element', function() {
draw.clear()
})
- it('redirects to toParent(doc)', function() {
- rect.toDoc()
- expect(rect.toParent).toHaveBeenCalledWith(rect.doc())
+ it('redirects to toParent(root)', function() {
+ rect.toRoot()
+ expect(rect.toParent).toHaveBeenCalledWith(rect.root())
})
})
@@ -613,10 +613,10 @@ describe('Element', function() {
})
})
- describe('doc()', function() {
+ describe('root()', function() {
it('returns the parent document', function() {
var rect = draw.rect(100,100)
- expect(rect.doc()).toBe(draw)
+ expect(rect.root()).toBe(draw)
})
})
@@ -819,7 +819,7 @@ describe('Element', function() {
describe('svg()', function() {
describe('without an argument', function() {
- it('returns full raw svg when called on the main svg doc', function() {
+ it('returns full raw svg when called on the root svg', function() {
draw.size(100,100).rect(100,100).id(null)
draw.circle(100).fill('#f06').id(null)
@@ -1023,7 +1023,7 @@ describe('Element', function() {
describe('defs()', function() {
it('returns the defs from the svg', function() {
var g = draw.group()
- expect(g.defs()).toBe(draw.doc().defs())
+ expect(g.defs()).toBe(draw.root().defs())
expect(g.defs() instanceof SVG.Defs).toBeTruthy()
})
})
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
})