| 259 | }; |
| 260 | |
| 261 | const patchProps = (el, oldProps, newProps) => { |
| 262 | // 新老节点对比,来查看值是否一样,如果不一样则触发修改 |
| 263 | if (oldProps !== newProps) { |
| 264 | for (const key in newProps) { |
| 265 | const prevProp = oldProps[key]; |
| 266 | const nextProp = newProps[key]; |
| 267 | if (prevProp !== nextProp) { |
| 268 | hostPatchProp(el, key, prevProp, nextProp); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | if (oldProps !== EMPTY_OBJ) { |
| 273 | for (const key in oldProps) { |
| 274 | if (!(key in oldProps)) { |
| 275 | hostPatchProp(el, key, oldProps[key], null); |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | }; |
| 281 | |
| 282 | function mountElement(vnode, container, parentComponent, anchor) { |
| 283 | // 这里的vnode --> element --> div |