summaryrefslogtreecommitdiffstats
path: root/src/HtmlNode.js
blob: 38309e31d2f0809e40d7648e8f56b4601a8ff480 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
SVG.HtmlNode = SVG.invent({
  create: function(element) {
    this.node = element
  }

, extend: {
    add: function(element, i) {
      element = createElement(element)
      if(element instanceof SVG.Nested) {
        element = new SVG.Doc(element.node)
        element.setData(JSON.parse(element.node.getAttribute('svgjs:data')) || {})
      }

      if (i == null)
        this.node.appendChild(element.node)
      else if (element.node != this.node.children[i])
        this.node.insertBefore(element.node, this.node.children[i])

      return this
    }

  , put: function(element, i) {
      this.add(element, i)
      return element
    }
  }
})