summaryrefslogtreecommitdiffstats
path: root/src/HtmlNode.js
blob: f674d0b43b48296b1d1fe85b4da04c1e312bac53 (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
import {makeInstance} from './adopter.js'
import Base from './Base.js'

export default class HtmlNode extends Base {
  constructor (element) {
    super(element, HtmlNode)
    this.node = element
  }

  add (element, i) {
    element = makeInstance(element)

    if (element.node !== this.node.children[i]) {
      this.node.insertBefore(element.node, this.node.children[i] || null)
    }

    return this
  }

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

  getEventTarget () {
    return this.node
  }
}