all files / directives/ text.js

100% Statements 16/16
75% Branches 3/4
100% Functions 2/2
100% Lines 16/16
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            13× 13×   12× 12× 12× 12× 12×   12× 12× 12× 12× 12× 12× 12×        
import { avalon, inBrowser } from '../seed/core'
 
 
avalon.directive('text', {
    delay: true,
    init: function () {
        
        var node = this.node
        if (node.isVoidTag) {
            avalon.error('自闭合元素不能使用ms-text')
        }
        var child = { nodeName: '#text', nodeValue: this.getValue() }
        node.children.splice(0, node.children.length, child)
        Eif(inBrowser){
           avalon.clearHTML(node.dom)
           node.dom.appendChild( avalon.vdom(child,'toDOM'))
        }
        this.node = child
        var type = 'expr'
        this.type = this.name = type
        var directive = avalon.directives[type]
        var me = this
        this.callback = function (value) {
            directive.update.call(me, me.node, value)
        }
    }
})