aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-11-30 22:20:07 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-11-30 22:20:07 +0100
commitdd2ad7824d546242468992436d9a631a60294e28 (patch)
treebd498a2b8949673db17ffaef880e220ceb346dcf /src
parent57ca267205f6c371d3328cc64355f111dbaf72a2 (diff)
downloadsvg.js-dd2ad7824d546242468992436d9a631a60294e28.tar.gz
svg.js-dd2ad7824d546242468992436d9a631a60294e28.zip
fixed bug related to the new path parser, text-method of tspan is a getter now, too
Diffstat (limited to 'src')
-rw-r--r--src/patharray.js25
-rw-r--r--src/text.js6
2 files changed, 17 insertions, 14 deletions
diff --git a/src/patharray.js b/src/patharray.js
index 6bf7276..03a9b7f 100644
--- a/src/patharray.js
+++ b/src/patharray.js
@@ -122,23 +122,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 = []
@@ -150,8 +149,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 59d85f8..9fb8fe3 100644
--- a/src/text.js
+++ b/src/text.js
@@ -63,12 +63,12 @@ SVG.Text = SVG.invent({
var text = ''
var children = this.node.childNodes
for(var i = 0, len = children.length; i < len; ++i){
-
+
// add newline if its not the first child and newLined is set to true
if(i != 0 && children[i].nodeType != 3 && SVG.adopt(children[i]).dom.newLined == true){
text += '\n'
}
-
+
// add content of this node
text += children[i].textContent
}
@@ -182,6 +182,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