diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arrange.js | 2 | ||||
-rw-r--r-- | src/element.js | 8 | ||||
-rw-r--r-- | src/flatten.js | 2 | ||||
-rw-r--r-- | src/helpers.js | 5 | ||||
-rw-r--r-- | src/parent.js | 14 | ||||
-rw-r--r-- | src/text.js | 11 |
6 files changed, 20 insertions, 22 deletions
diff --git a/src/arrange.js b/src/arrange.js index 904381f..15d3d3c 100644 --- a/src/arrange.js +++ b/src/arrange.js @@ -15,7 +15,7 @@ SVG.extend(SVG.Element, { return this.siblings()[this.position() + 1] } // Get the next element (will return null if there is none) -, previous: function() { +, prev: function() { return this.siblings()[this.position() - 1] } // Send given element one step forward diff --git a/src/element.js b/src/element.js index cedaf2d..a4eda1f 100644 --- a/src/element.js +++ b/src/element.js @@ -221,11 +221,9 @@ SVG.Element = SVG.invent({ well.innerHTML = svg // transplant nodes - for (len = well.childNodes.length;len--;) - if(well.firstChild.nodeType != 1) - well.removeChild(well.firstChild) - else - this.node.appendChild(well.firstChild) + for (len = well.children.length;len--;) { + this.node.appendChild(well.firstElementChild) + } // otherwise act as a getter } else { diff --git a/src/flatten.js b/src/flatten.js index db9b9df..356a176 100644 --- a/src/flatten.js +++ b/src/flatten.js @@ -11,7 +11,7 @@ SVG.extend(SVG.Parent, { }) // we need this so that SVG.Doc does not get removed - this.node.firstChild || this.remove() + this.node.firstElementChild || this.remove() return this } diff --git a/src/helpers.js b/src/helpers.js index 6a07482..7b58727 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -149,9 +149,8 @@ function arrayToString(a) { // Deep new id assignment function assignNewId(node) { // do the same for SVG child nodes as well - for (var i = node.childNodes.length - 1; i >= 0; i--) - if (node.childNodes[i] instanceof window.SVGElement) - assignNewId(node.childNodes[i]) + for (var i = node.children.length - 1; i >= 0; i--) + assignNewId(node.children[i]) if(node.id) return SVG.adopt(node).id(SVG.eid(node.nodeName)) diff --git a/src/parent.js b/src/parent.js index ee99e4d..67d2d73 100644 --- a/src/parent.js +++ b/src/parent.js @@ -11,7 +11,7 @@ SVG.Parent = SVG.invent({ , extend: { // Returns all child elements children: function() { - return SVG.utils.map(SVG.utils.filterSVGElements(this.node.childNodes), function(node) { + return SVG.utils.map(this.node.children, function(node) { return SVG.adopt(node) }) } @@ -19,8 +19,8 @@ SVG.Parent = SVG.invent({ , add: function(element, i) { if (i == null) this.node.appendChild(element.node) - else if (element.node != this.node.childNodes[i]) - this.node.insertBefore(element.node, this.node.childNodes[i]) + else if (element.node != this.node.children[i]) + this.node.insertBefore(element.node, this.node.children[i]) return this } @@ -35,11 +35,11 @@ SVG.Parent = SVG.invent({ } // Gets index of given element , index: function(element) { - return [].slice.call(this.node.childNodes).indexOf(element.node) + return [].slice.call(this.node.children).indexOf(element.node) } // Get a element at the given index , get: function(i) { - return SVG.adopt(this.node.childNodes[i]) + return SVG.adopt(this.node.children[i]) } // Get first child , first: function() { @@ -47,7 +47,7 @@ SVG.Parent = SVG.invent({ } // Get the last child , last: function() { - return this.get(this.node.childNodes.length - 1) + return this.get(this.node.children.length - 1) } // Iterates over all children and invokes a given block , each: function(block, deep) { @@ -58,7 +58,7 @@ SVG.Parent = SVG.invent({ if (children[i] instanceof SVG.Element) block.apply(children[i], [i, children]) - if (deep && (children[i] instanceof SVG.Container)) + if (deep && (children[i] instanceof SVG.Parent)) children[i].each(block, deep) } diff --git a/src/text.js b/src/text.js index 1e93db7..fa14894 100644 --- a/src/text.js +++ b/src/text.js @@ -46,10 +46,11 @@ SVG.Text = SVG.invent({ // Set the text content , text: function(text) { // act as getter - if (typeof text === 'undefined'){ + if (text === undefined){ var text = '' - var children = this.node.childNodes - var firstLine = 0 + , children = this.node.childNodes + , firstLine = 0 + for(var i = 0, len = children.length; i < len; ++i){ // skip textPaths - they are no lines if(children[i].nodeName == 'textPath') { @@ -114,11 +115,11 @@ SVG.Text = SVG.invent({ var self = this , blankLineOffset = 0 , dy = this.dom.leading * new SVG.Number(this.attr('font-size')) - + this.each(function() { if (this.dom.newLined) { this.attr('x', self.attr('x')) - + if(this.text() == '\n') { blankLineOffset += dy }else{ |