diff options
author | Paulo F. Silva <paulo@pjfs.pt> | 2016-03-02 17:13:33 +0000 |
---|---|---|
committer | Paulo F. Silva <paulo@pjfs.pt> | 2016-03-02 17:13:33 +0000 |
commit | c66d24ab5cb2e635bc0d77299ae5fbdad8e30508 (patch) | |
tree | 8054de51c7fcf04fd5f17e3528b5b1bf934279bc | |
parent | 4856081d28f08979b33405da399fac424ea2a350 (diff) | |
download | svg.js-c66d24ab5cb2e635bc0d77299ae5fbdad8e30508.tar.gz svg.js-c66d24ab5cb2e635bc0d77299ae5fbdad8e30508.zip |
Backports commit dd2ad7824d546242468992436d9a631a60294e28 to v1.x branch
-rw-r--r-- | src/patharray.js | 25 | ||||
-rw-r--r-- | src/text.js | 3 |
2 files changed, 15 insertions, 13 deletions
diff --git a/src/patharray.js b/src/patharray.js index d778fbf..60a8cf4 100644 --- a/src/patharray.js +++ b/src/patharray.js @@ -123,23 +123,22 @@ SVG.extend(SVG.PathArray, { .trim() // trim .split(SVG.regex.whitespaces) // split into array + // at this place there could be parts like ['3.124.854.32'] because we could not determine the point as seperator till now + // we fix this elements in the next loop + for(i = array.length; --i;){ + if(array[i].indexOf('.') != array[i].lastIndexOf('.')){ + var split = array[i].split('.') // split at the point + var first = [split.shift(), split.shift()].join('.') // join the first number together + array.splice.apply(array, [i, 1].concat(first, split.map(function(el){ return '.'+el }))) // add first and all other entries back to array + } + } + }else{ array = array.reduce(function(prev, curr){ return [].concat.apply(prev, curr) }, []) } - // at this place there could be parts like ['3.124.854.32'] because we could not determine the point as seperator till now - // we fix this elements in the next loop - for(i = 0; i < array.length; ++i){ - if(array[i].indexOf('.') != array[i].lastIndexOf('.')){ - var split = array[i].split('.') // split at the point - var first = [split.shift(), split.shift()].join('.') // join the first number together - array.splice.apply(array, [i, 1].concat(first, split.map(function(el){ return '.'+el }))) // add first and all other entries back to array - i += split.length // dont forget to update the index - } - } - // array now is an array containing all parts of a path e.g. ['M', '0', '0', 'L', '30', '30' ...] var arr = [] @@ -151,8 +150,10 @@ SVG.extend(SVG.PathArray, { s = array[0] array.shift() // If last letter was a move command and we got no new, it defaults to [L]ine - }else if(s.toUpperCase() == 'M'){ + }else if(s == 'M'){ s = 'L' + }else if(s == 'm'){ + s = 'l' } // add path letter as first element diff --git a/src/text.js b/src/text.js index 38d4ecc..911b31b 100644 --- a/src/text.js +++ b/src/text.js @@ -1,4 +1,3 @@ - SVG.Text = SVG.invent({ // Initialize node create: function() { @@ -142,6 +141,8 @@ SVG.TSpan = SVG.invent({ , extend: { // Set text content text: function(text) { + if(text == null) return this.node.textContent + (this.dom.newLined ? '\n' : '') + typeof text === 'function' ? text.call(this, this) : this.plain(text) return this |