From 7b8e6f1d5afe2472cd1245f9bb73b6d59238e541 Mon Sep 17 00:00:00 2001 From: wout Date: Mon, 25 Aug 2014 10:33:35 +0200 Subject: Removed internal references from SVG.Text --- src/textpath.js | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'src/textpath.js') diff --git a/src/textpath.js b/src/textpath.js index 0ee9d77..03dfbee 100755 --- a/src/textpath.js +++ b/src/textpath.js @@ -12,31 +12,42 @@ SVG.TextPath = SVG.invent({ , construct: { // Create path for text to run on path: function(d) { - /* create textPath element */ - this.textPath = new SVG.TextPath + // create textPath element + var path = new SVG.TextPath + , track = this.doc().defs().path(d) - /* move lines to textpath */ - while(this.node.hasChildNodes()) - this.textPath.node.appendChild(this.node.firstChild) + // move lines to textpath + while (this.node.hasChildNodes()) + path.node.appendChild(this.node.firstChild) - /* add textPath element as child node */ - this.node.appendChild(this.textPath.node) + // add textPath element as child node + this.node.appendChild(path.node) - /* create path in defs */ - this.track = this.doc().defs().path(d) - - /* create circular reference */ - this.textPath.parent = this - - /* link textPath to path and add content */ - this.textPath.attr('href', '#' + this.track, SVG.xlink) + // link textPath to path and add content + path.attr('href', '#' + track, SVG.xlink) return this } // Plot path if any , plot: function(d) { - if (this.track) this.track.plot(d) + var track = this.track() + + if (track) + track.plot(d) + return this } + // Get the path track element + , track: function() { + var path = this.textPath() + + if (path) + return path.reference('href') + } + // Get the textPath child + , textPath: function() { + if (this.node.firstChild && this.node.firstChild.nodeName == 'textPath') + return SVG.adopt(this.node.firstChild) + } } }) \ No newline at end of file -- cgit v1.2.3