aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/TextPath.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-08 19:49:49 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-11-08 19:49:49 +0100
commit09e7d0b595da5a2e86e375ea4bd9bd7aba02c588 (patch)
treeae4d2df2887187bed13756c0cc79657cca680cf2 /src/elements/TextPath.js
parent8c81fb7c2e6e9842570d27a84b1a1c600c82c16b (diff)
downloadsvg.js-09e7d0b595da5a2e86e375ea4bd9bd7aba02c588.tar.gz
svg.js-09e7d0b595da5a2e86e375ea4bd9bd7aba02c588.zip
added possibility to pass in additional attribues to element creators (#796)
e.g. - `canvas.rect({x:100})` or - `canvas.rect(100, 100, {x:100})`
Diffstat (limited to 'src/elements/TextPath.js')
-rw-r--r--src/elements/TextPath.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/elements/TextPath.js b/src/elements/TextPath.js
index cddeda8..324d768 100644
--- a/src/elements/TextPath.js
+++ b/src/elements/TextPath.js
@@ -1,10 +1,10 @@
-import { nodeOrNew, register } from '../utils/adopter.js'
+import { nodeOrNew, register, wrapWithAttrCheck } from '../utils/adopter.js'
import { registerMethods } from '../utils/methods.js'
import { xlink } from '../modules/core/namespaces.js'
-import baseFind from '../modules/core/selector.js'
import Path from './Path.js'
import PathArray from '../types/PathArray.js'
import Text from './Text.js'
+import baseFind from '../modules/core/selector.js'
export default class TextPath extends Text {
// Initialize node
@@ -39,13 +39,13 @@ export default class TextPath extends Text {
registerMethods({
Container: {
- textPath (text, path) {
+ textPath: wrapWithAttrCheck(function (text, path) {
return this.defs().path(path).text(text).addTo(this)
- }
+ })
},
Text: {
// Create path for text to run on
- path (track) {
+ path: wrapWithAttrCheck(function (track) {
var path = new TextPath()
// if track is a path, reuse it
@@ -59,7 +59,7 @@ registerMethods({
// add textPath element as child node and return textPath
return this.put(path)
- },
+ }),
// Get the textPath children
textPath () {
@@ -68,13 +68,13 @@ registerMethods({
},
Path: {
// creates a textPath from this path
- text (text) {
+ text: wrapWithAttrCheck(function (text) {
if (text instanceof Text) {
var txt = text.text()
return text.clear().path(this).text(txt)
}
return this.parent().put(new Text()).path(this).text(text)
- },
+ }),
targets () {
return baseFind('svg [href*="' + this.id() + '"]')