summaryrefslogtreecommitdiffstats
path: root/src/doc.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-06-25 15:05:03 +0200
committerwout <wout@impinc.co.uk>2014-06-25 15:05:03 +0200
commite567c774c17e6649041d4972defd1232ab602012 (patch)
tree05140fe4715a652c99f15672e1d56c0fc8426824 /src/doc.js
parentec21f496bddc588e2113fd5418d713ce8ae78f39 (diff)
downloadsvg.js-e567c774c17e6649041d4972defd1232ab602012.tar.gz
svg.js-e567c774c17e6649041d4972defd1232ab602012.zip
Added SVG.Circle, removed structural internal references
Diffstat (limited to 'src/doc.js')
-rwxr-xr-xsrc/doc.js43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/doc.js b/src/doc.js
index 1a025f3..1e19ec7 100755
--- a/src/doc.js
+++ b/src/doc.js
@@ -1,25 +1,24 @@
SVG.Doc = SVG.invent({
// Initialize node
create: function(element) {
- /* ensure the presence of a dom element */
- element = typeof element == 'string' ?
- document.getElementById(element) :
- element
-
- /* If the target is an svg element, use that element as the main wrapper.
- This allows svg.js to work with svg documents as well. */
- if (element.nodeName == 'svg') {
- this.constructor.call(this, element)
- } else {
- this.constructor.call(this, SVG.create('svg'))
- element.appendChild(this.node)
+ if (element) {
+ /* ensure the presence of a dom element */
+ element = typeof element == 'string' ?
+ document.getElementById(element) :
+ element
+
+ /* If the target is an svg element, use that element as the main wrapper.
+ This allows svg.js to work with svg documents as well. */
+ if (element.nodeName == 'svg') {
+ this.constructor.call(this, element)
+ } else {
+ this.constructor.call(this, SVG.create('svg'))
+ element.appendChild(this.node)
+ }
+
+ /* set svg element attributes and ensure defs node */
+ this.namespace().size('100%', '100%').defs()
}
-
- /* set svg element attributes and ensure defs node */
- this
- .attr({ xmlns: SVG.ns, version: '1.1', width: '100%', height: '100%' })
- .attr('xmlns:xlink', SVG.xlink, SVG.xmlns)
- .defs()
}
// Inherit from
@@ -27,8 +26,14 @@ SVG.Doc = SVG.invent({
// Add class methods
, extend: {
+ // Add namespaces
+ namespace: function() {
+ return this
+ .attr({ xmlns: SVG.ns, version: '1.1' })
+ .attr('xmlns:xlink', SVG.xlink, SVG.xmlns)
+ }
// Creates and returns defs element
- defs: function() {
+ , defs: function() {
if (!this._defs) {
var defs