Good work.

pull/1/head
Alberto Martínez 10 years ago
parent 91a001e501
commit 63ffd53f5c

@ -66,7 +66,7 @@ function updateProps(elm, oldProps, props) {
for (name in val) {
on = val[name];
if (on !== oldProps.style[name]) {
elm.style[name] = val[name];
elm.style[name] = on;
}
}
} else if (key === 'class') {
@ -86,12 +86,12 @@ function createElm(vnode) {
var elm, children;
if (!isUndef(vnode.tag)) {
elm = document.createElement(vnode.tag);
if (!isUndef(vnode.tag)) {
if (!isUndef(vnode.props)) {
updateProps(elm, emptyNode.props, vnode.props);
}
children = vnode.children;
if (isArr(children)) {
for (var i = 0; i < vnode.children.length; ++i) {
for (var i = 0; i < children.length; ++i) {
elm.appendChild(createElm(children[i]));
}
} else if (isPrimitive(vnode.text)) {
@ -111,9 +111,9 @@ function sameVnode(vnode1, vnode2) {
function createKeyToOldIdx(children, beginIdx, endIdx) {
var i, map = {};
for (i = beginIdx; i <= endIdx; ++i) {
var ch = children[i];
if (!isUndef(ch.props) && !isUndef(ch.props.key)) {
map[ch.props.key] = i;
var props = children[i].props;
if (!isUndef(props) && !isUndef(props.key)) {
map[props.key] = i;
}
}
return map;
@ -192,8 +192,8 @@ function updateChildren(parentElm, oldCh, newCh) {
for (; oldStartIdx <= oldEndIdx; ++oldStartIdx) {
var ch = oldCh[oldStartIdx];
if (!isUndef(ch)) {
parentElm.removeChild(oldCh[oldStartIdx].elm);
oldCh[oldStartIdx].elm = undefined;
parentElm.removeChild(ch.elm);
ch.elm = undefined;
}
}
}

Loading…
Cancel
Save