Sha256: f9ab17cd6e758f31ff6c6bd6b22ac3e18f14f7605bab965c0111fd9526d0c8d5
Contents?: true
Size: 1021 Bytes
Versions: 14
Compression:
Stored size: 1021 Bytes
Contents
var utils = require('../utils'), slice = [].slice /** * Binding for innerHTML */ module.exports = { bind: function () { // a comment node means this is a binding for // {{{ inline unescaped html }}} if (this.el.nodeType === 8) { // hold nodes this.nodes = [] } }, update: function (value) { value = utils.guard(value) if (this.nodes) { this.swap(value) } else { this.el.innerHTML = value } }, swap: function (value) { var parent = this.el.parentNode, nodes = this.nodes, i = nodes.length // remove old nodes while (i--) { parent.removeChild(nodes[i]) } // convert new value to a fragment var frag = utils.toFragment(value) // save a reference to these nodes so we can remove later this.nodes = slice.call(frag.childNodes) parent.insertBefore(frag, this.el) } }
Version data entries
14 entries across 14 versions & 1 rubygems