build
This commit is contained in:
commit
8b168deef4
6 changed files with 82 additions and 53 deletions
|
|
@ -78,12 +78,14 @@ module.exports = function($window) {
|
|||
setAttrs(vnode, attrs, ns)
|
||||
}
|
||||
|
||||
if (vnode.text != null) {
|
||||
if (vnode.attrs != null && vnode.attrs.contenteditable != null) {
|
||||
setContentEditable(vnode)
|
||||
}
|
||||
else if (vnode.text != null) {
|
||||
if (vnode.text !== "") element.textContent = vnode.text
|
||||
else vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)]
|
||||
}
|
||||
|
||||
if (vnode.children != null) {
|
||||
else if (vnode.children != null) {
|
||||
var children = vnode.children
|
||||
createNodes(element, children, 0, children.length, hooks, null, ns)
|
||||
setLateAttrs(vnode)
|
||||
|
|
@ -254,7 +256,10 @@ module.exports = function($window) {
|
|||
}
|
||||
}
|
||||
updateAttrs(vnode, old.attrs, vnode.attrs, ns)
|
||||
if (old.text != null && vnode.text != null && vnode.text !== "") {
|
||||
if (vnode.attrs != null && vnode.attrs.contenteditable != null) {
|
||||
setContentEditable(vnode)
|
||||
}
|
||||
else if (old.text != null && vnode.text != null && vnode.text !== "") {
|
||||
if (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text
|
||||
}
|
||||
else {
|
||||
|
|
@ -329,6 +334,15 @@ module.exports = function($window) {
|
|||
else parent.appendChild(dom)
|
||||
}
|
||||
|
||||
function setContentEditable(vnode) {
|
||||
var children = vnode.children
|
||||
if (children != null && children.length === 1 && children[0].tag === "<") {
|
||||
var content = children[0].children
|
||||
if (vnode.dom.innerHTML !== content) vnode.dom.innerHTML = content
|
||||
}
|
||||
else if (children != null || vnode.text != null) throw new Error("Child node of a contenteditable must be trusted")
|
||||
}
|
||||
|
||||
//remove
|
||||
function removeNodes(parent, vnodes, start, end, context) {
|
||||
for (var i = start; i < end; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue