UNPKG

avalon2

Version:

an elegant efficient express mvvm framework

25 lines (21 loc) 654 B
import { avalon } from '../seed/core' avalon.directive('html', { update: function(vdom, value) { this.beforeDispose() this.innerRender = avalon.scan('<div class="ms-html-container">' + value + '</div>', this.vm, function() { var oldRoot = this.root if(vdom.children) vdom.children.length = 0 vdom.children = oldRoot.children this.root = vdom if (vdom.dom) avalon.clearHTML(vdom.dom) }) }, beforeDispose: function() { if (this.innerRender) { this.innerRender.dispose() } }, delay: true })