summaryrefslogtreecommitdiffstats
path: root/src/Bare.js
blob: 783fa6a7c29d1f1d38ae285bf2831fba3bc8bfea (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
28
29
30
31
32
33
34
35
36
37
38
import {nodeOrNew} from './tools.js'
import Parent from './Parent.js'

export default function Bare (element, inherit) {
  return class Custom extends inherit {
    constructor (node) {
      super(nodeOrNew(element, node))
    }

    words (text) {
      // remove contents
      while (this.node.hasChildNodes()) {
        this.node.removeChild(this.node.lastChild)
      }

      // create text node
      this.node.appendChild(document.createTextNode(text))

      return this
    }
  }
}

export let constructors = {
  // Create an element that is not described by SVG.js
  element: function (element, inherit) {
    let custom = createCustom(element, inherit)
    return this.put(new custom())
  }
}

// extend(Parent, {
//   // Create an element that is not described by SVG.js
//   element: function (element, inherit) {
//     let custom = createCustom(element, inherit)
//     return this.put(new custom())
//   }
// })