Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
feat: old dom attr
Browse files Browse the repository at this point in the history
  • Loading branch information
zeromake committed Dec 20, 2017
1 parent a3d5351 commit 9ca8ade
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/vdom/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ function idiff(
let props = vdom.props;
// 获取虚拟的子节点
const vchildren = (vnode as VNode).children;
// dom可能进行过原生操作
if (props && typeof props === "object") {
for (let a = out.attributes, i = a.length; i-- ; ) {
const attr = a[i];
if (!(attr.name in props)) {
props[attr.name] = attr.value;
}
}
}
if (props == null || typeof props === "boolean") {
// 上回的props不存在说明,这次一般为新建(preact有可能通过原生dom操作删除)
vdom.props = props = {};
Expand All @@ -200,6 +209,7 @@ function idiff(
props[attr.name] = attr.value;
}
}

if (
!hydrating
&& vchildren
Expand Down

0 comments on commit 9ca8ade

Please sign in to comment.