|
1 |
| -var _ = require('../../util') |
2 | 1 | import { parseTemplate } from '../../parsers/template'
|
| 2 | +import { |
| 3 | + createAnchor, |
| 4 | + before, |
| 5 | + replace, |
| 6 | + remove, |
| 7 | + _toString, |
| 8 | + toArray |
| 9 | +} from '../../util' |
3 | 10 |
|
4 |
| -module.exports = { |
| 11 | +export default { |
5 | 12 |
|
6 |
| - bind: function () { |
| 13 | + bind () { |
7 | 14 | // a comment node means this is a binding for
|
8 | 15 | // {{{ inline unescaped html }}}
|
9 | 16 | if (this.el.nodeType === 8) {
|
10 | 17 | // hold nodes
|
11 | 18 | this.nodes = []
|
12 | 19 | // replace the placeholder with proper anchor
|
13 |
| - this.anchor = _.createAnchor('v-html') |
14 |
| - _.replace(this.el, this.anchor) |
| 20 | + this.anchor = createAnchor('v-html') |
| 21 | + replace(this.el, this.anchor) |
15 | 22 | }
|
16 | 23 | },
|
17 | 24 |
|
18 |
| - update: function (value) { |
19 |
| - value = _._toString(value) |
| 25 | + update (value) { |
| 26 | + value = _toString(value) |
20 | 27 | if (this.nodes) {
|
21 | 28 | this.swap(value)
|
22 | 29 | } else {
|
23 | 30 | this.el.innerHTML = value
|
24 | 31 | }
|
25 | 32 | },
|
26 | 33 |
|
27 |
| - swap: function (value) { |
| 34 | + swap (value) { |
28 | 35 | // remove old nodes
|
29 | 36 | var i = this.nodes.length
|
30 | 37 | while (i--) {
|
31 |
| - _.remove(this.nodes[i]) |
| 38 | + remove(this.nodes[i]) |
32 | 39 | }
|
33 | 40 | // convert new value to a fragment
|
34 | 41 | // do not attempt to retrieve from id selector
|
35 | 42 | var frag = parseTemplate(value, true, true)
|
36 | 43 | // save a reference to these nodes so we can remove later
|
37 |
| - this.nodes = _.toArray(frag.childNodes) |
38 |
| - _.before(frag, this.anchor) |
| 44 | + this.nodes = toArray(frag.childNodes) |
| 45 | + before(frag, this.anchor) |
39 | 46 | }
|
40 | 47 | }
|
0 commit comments