diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/doc.js | 8 | ||||
-rw-r--r-- | src/element.js | 20 |
2 files changed, 15 insertions, 13 deletions
@@ -2,15 +2,17 @@ SVG.Doc = function Doc(e) { this.constructor.call(this, SVG.create('svg')); + // ensure the presence of a html element + if (typeof e == 'string') + e = document.getElementById(e); + // set this. attr({ xmlns: SVG.ns, version: '1.1' }). attr('xlink', SVG.xlink, SVG.ns). + size(e.offsetWidth, e.offsetHeight). defs(); - if (typeof e == 'string') - e = document.getElementById(e); - e.appendChild(this.node); }; diff --git a/src/element.js b/src/element.js index 981f9a0..5664f46 100644 --- a/src/element.js +++ b/src/element.js @@ -50,15 +50,6 @@ SVG.extend(SVG.Element, { else return this.attrs[a]; - } else if (this._isStyle(a)) { - a == 'text' ? - this.text(v) : - a == 'leading' ? - this[a] = v : - this.style[a] = v; - - this.text(this.content); - } else { this.attrs[a] = v; if (a == 'x' && this._isText()) @@ -68,7 +59,16 @@ SVG.extend(SVG.Element, { n != null ? this.node.setAttributeNS(n, a, v) : this.node.setAttribute(a, v); - + + if (this._isStyle(a)) { + a == 'text' ? + this.text(v) : + a == 'leading' ? + this[a] = v : + this.style[a] = v; + + this.text(this.content); + } } return this; |