blob: c762a2bd920fca842ec276b928c3fe9f8a040644 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// Adopt existing svg elements
SVG.adopt = function(node) {
// Make sure a node isn't already adopted
if (node.instance) return node.instance
// Initialize variables
var element
// Adopt with element-specific settings
if (node.nodeName == 'svg')
element = node.parentNode instanceof SVGElement ? new SVG.Nested : new SVG.Doc
else if (node.nodeName == 'lineairGradient')
element = new SVG.Gradient('lineair')
else if (node.nodeName == 'radialGradient')
element = new SVG.Gradient('radial')
else
element = new SVG[capitalize(node.nodeName)]
// Ensure references
element.type = node.nodeName
element.node = node
return node.instance = element
}
|