From 75fe71014bb47423cb662daa12c68b518ddadc32 Mon Sep 17 00:00:00 2001 From: Aiden Bai Date: Fri, 22 Oct 2021 14:14:05 -0700 Subject: [PATCH 1/2] fix(patch): dupe keyed patching --- package.json | 4 +- pnpm-lock.yaml | 110 ++++++++++++++++++++-------------------- src/drivers/children.ts | 11 +++- src/patch.ts | 11 ++-- 4 files changed, 74 insertions(+), 62 deletions(-) diff --git a/package.json b/package.json index fe7fe595bd..7df26804f4 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "@testing-library/dom": "^8.10.1", "@types/glob": "^7.2.0", "@types/jest": "^27.0.2", - "@types/node": "^16.11.2", + "@types/node": "^16.11.4", "@typescript-eslint/eslint-plugin": "^5.1.0", "@typescript-eslint/parser": "^4.33.0", "benchmark": "^2.1.4", @@ -100,7 +100,7 @@ "rollup-plugin-ts": "^1.4.7", "simple-virtual-dom": "^0.1.10", "snabbdom": "^3.1.0", - "ts-node": "^10.3.1", + "ts-node": "^10.4.0", "tslib": "^2.3.1", "typescript": "^4.4.4", "virtual-dom": "^2.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fed9f9d165..8a249812c5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,7 +12,7 @@ specifiers: '@testing-library/dom': ^8.10.1 '@types/glob': ^7.2.0 '@types/jest': ^27.0.2 - '@types/node': ^16.11.2 + '@types/node': ^16.11.4 '@typescript-eslint/eslint-plugin': ^5.1.0 '@typescript-eslint/parser': ^4.33.0 benchmark: ^2.1.4 @@ -32,7 +32,7 @@ specifiers: rollup-plugin-ts: ^1.4.7 simple-virtual-dom: ^0.1.10 snabbdom: ^3.1.0 - ts-node: ^10.3.1 + ts-node: ^10.4.0 tslib: ^2.3.1 typescript: ^4.4.4 virtual-dom: ^2.1.1 @@ -51,7 +51,7 @@ devDependencies: '@testing-library/dom': 8.10.1 '@types/glob': 7.2.0 '@types/jest': 27.0.2 - '@types/node': 16.11.2 + '@types/node': 16.11.4 '@typescript-eslint/eslint-plugin': 5.1.0_f127894afb221e47dc494017f42e8f05 '@typescript-eslint/parser': 4.33.0_eslint@8.0.1+typescript@4.4.4 benchmark: 2.1.4 @@ -60,7 +60,7 @@ devDependencies: github-markdown-css: 5.0.0 glob: 7.2.0 husky: 7.0.4 - jest: 27.3.1_ts-node@10.3.1 + jest: 27.3.1_ts-node@10.4.0 lint-staged: 11.2.3 lodash: 4.17.21 ora: 6.0.1 @@ -71,7 +71,7 @@ devDependencies: rollup-plugin-ts: 1.4.7_rollup@2.58.0+typescript@4.4.4 simple-virtual-dom: 0.1.10 snabbdom: 3.1.0 - ts-node: 10.3.1_14436a5918f235eb1b9267bff073cfe7 + ts-node: 10.4.0_bada05a3e1cd24c0fc5f82f6eaa2ca15 tslib: 2.3.1 typescript: 4.4.4 virtual-dom: 2.1.1 @@ -1490,14 +1490,14 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 chalk: 4.1.2 jest-message-util: 27.3.1 jest-util: 27.3.1 slash: 3.0.0 dev: true - /@jest/core/27.3.1_ts-node@10.3.1: + /@jest/core/27.3.1_ts-node@10.4.0: resolution: {integrity: sha512-DMNE90RR5QKx0EA+wqe3/TNEwiRpOkhshKNxtLxd4rt3IZpCt+RSL+FoJsGeblRZmqdK4upHA/mKKGPPRAifhg==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} peerDependencies: @@ -1511,14 +1511,14 @@ packages: '@jest/test-result': 27.3.1 '@jest/transform': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.8.1 exit: 0.1.2 graceful-fs: 4.2.8 jest-changed-files: 27.3.0 - jest-config: 27.3.1_ts-node@10.3.1 + jest-config: 27.3.1_ts-node@10.4.0 jest-haste-map: 27.3.1 jest-message-util: 27.3.1 jest-regex-util: 27.0.6 @@ -1548,7 +1548,7 @@ packages: dependencies: '@jest/fake-timers': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 jest-mock: 27.3.0 dev: true @@ -1558,7 +1558,7 @@ packages: dependencies: '@jest/types': 27.2.5 '@sinonjs/fake-timers': 8.0.1 - '@types/node': 16.11.2 + '@types/node': 16.11.4 jest-message-util: 27.3.1 jest-mock: 27.3.0 jest-util: 27.3.1 @@ -1587,7 +1587,7 @@ packages: '@jest/test-result': 27.3.1 '@jest/transform': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 chalk: 4.1.2 collect-v8-coverage: 1.0.1 exit: 0.1.2 @@ -1671,7 +1671,7 @@ packages: dependencies: '@types/istanbul-lib-coverage': 2.0.3 '@types/istanbul-reports': 3.0.1 - '@types/node': 16.11.2 + '@types/node': 16.11.4 '@types/yargs': 16.0.4 chalk: 4.1.2 dev: true @@ -2073,20 +2073,20 @@ packages: /@types/fs-extra/9.0.13: resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} dependencies: - '@types/node': 16.11.2 + '@types/node': 16.11.4 dev: true /@types/glob/7.2.0: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: '@types/minimatch': 3.0.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 dev: true /@types/graceful-fs/4.1.5: resolution: {integrity: sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==} dependencies: - '@types/node': 16.11.2 + '@types/node': 16.11.4 dev: true /@types/istanbul-lib-coverage/2.0.3: @@ -2127,7 +2127,7 @@ packages: /@types/node-fetch/2.5.12: resolution: {integrity: sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==} dependencies: - '@types/node': 16.11.2 + '@types/node': 16.11.4 form-data: 3.0.1 dev: true @@ -2135,8 +2135,8 @@ packages: resolution: {integrity: sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A==} dev: true - /@types/node/16.11.2: - resolution: {integrity: sha512-w34LtBB0OkDTs19FQHXy4Ig/TOXI4zqvXS2Kk1PAsRKZ0I+nik7LlMYxckW0tSNGtvWmzB+mrCTbuEjuB9DVsw==} + /@types/node/16.11.4: + resolution: {integrity: sha512-TMgXmy0v2xWyuCSCJM6NCna2snndD8yvQF67J29ipdzMcsPa9u+o0tjF5+EQNdhcuZplYuouYqpc4zcd5I6amQ==} dev: true /@types/normalize-package-data/2.4.1: @@ -2158,7 +2158,7 @@ packages: /@types/resolve/1.17.1: resolution: {integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==} dependencies: - '@types/node': 16.11.2 + '@types/node': 16.11.4 dev: true /@types/semver/7.3.9: @@ -2776,11 +2776,11 @@ packages: '@types/semver': 7.3.9 '@types/ua-parser-js': 0.7.36 browserslist: 4.17.1 - caniuse-lite: 1.0.30001270 + caniuse-lite: 1.0.30001271 isbot: 3.3.3 object-path: 0.11.8 semver: 7.3.5 - ua-parser-js: 0.7.28 + ua-parser-js: 0.7.30 dev: true /browserslist/4.17.1: @@ -2788,7 +2788,7 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001270 + caniuse-lite: 1.0.30001271 electron-to-chromium: 1.3.877 escalade: 3.1.1 nanocolors: 0.1.12 @@ -2800,7 +2800,7 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001270 + caniuse-lite: 1.0.30001271 electron-to-chromium: 1.3.877 escalade: 3.1.1 node-releases: 2.0.1 @@ -2892,8 +2892,8 @@ packages: resolution: {integrity: sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs=} dev: true - /caniuse-lite/1.0.30001270: - resolution: {integrity: sha512-TcIC7AyNWXhcOmv2KftOl1ShFAaHQYcB/EPL/hEyMrcS7ZX0/DvV1aoy6BzV0+16wTpoAyTMGDNAJfSqS/rz7A==} + /caniuse-lite/1.0.30001271: + resolution: {integrity: sha512-BBruZFWmt3HFdVPS8kceTBIguKxu4f99n5JNp06OlPD/luoAMIaIK5ieV5YjnBLH3Nysai9sxj9rpJj4ZisXOA==} dev: true /caseless/0.12.0: @@ -3040,8 +3040,8 @@ packages: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} dev: true - /commander/8.2.0: - resolution: {integrity: sha512-LLKxDvHeL91/8MIyTAD5BFMNtoIwztGPMiM/7Bl8rIPmHCZXRxmSWr91h57dpOpnQ6jIUqEWdXE/uBYMfiVZDA==} + /commander/8.3.0: + resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==} engines: {node: '>= 12'} dev: true @@ -4569,7 +4569,7 @@ packages: '@jest/environment': 27.3.1 '@jest/test-result': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 chalk: 4.1.2 co: 4.6.0 dedent: 0.7.0 @@ -4589,7 +4589,7 @@ packages: - supports-color dev: true - /jest-cli/27.3.1_ts-node@10.3.1: + /jest-cli/27.3.1_ts-node@10.4.0: resolution: {integrity: sha512-WHnCqpfK+6EvT62me6WVs8NhtbjAS4/6vZJnk7/2+oOr50cwAzG4Wxt6RXX0hu6m1169ZGMlhYYUNeKBXCph/Q==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} hasBin: true @@ -4599,14 +4599,14 @@ packages: node-notifier: optional: true dependencies: - '@jest/core': 27.3.1_ts-node@10.3.1 + '@jest/core': 27.3.1_ts-node@10.4.0 '@jest/test-result': 27.3.1 '@jest/types': 27.2.5 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.8 import-local: 3.0.3 - jest-config: 27.3.1_ts-node@10.3.1 + jest-config: 27.3.1_ts-node@10.4.0 jest-util: 27.3.1 jest-validate: 27.3.1 prompts: 2.4.2 @@ -4619,7 +4619,7 @@ packages: - utf-8-validate dev: true - /jest-config/27.3.1_ts-node@10.3.1: + /jest-config/27.3.1_ts-node@10.4.0: resolution: {integrity: sha512-KY8xOIbIACZ/vdYCKSopL44I0xboxC751IX+DXL2+Wx6DKNycyEfV3rryC3BPm5Uq/BBqDoMrKuqLEUNJmMKKg==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} peerDependencies: @@ -4649,7 +4649,7 @@ packages: jest-validate: 27.3.1 micromatch: 4.0.4 pretty-format: 27.3.1 - ts-node: 10.3.1_14436a5918f235eb1b9267bff073cfe7 + ts-node: 10.4.0_bada05a3e1cd24c0fc5f82f6eaa2ca15 transitivePeerDependencies: - bufferutil - canvas @@ -4692,7 +4692,7 @@ packages: '@jest/environment': 27.3.1 '@jest/fake-timers': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 jest-mock: 27.3.0 jest-util: 27.3.1 jsdom: 16.7.0 @@ -4710,7 +4710,7 @@ packages: '@jest/environment': 27.3.1 '@jest/fake-timers': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 jest-mock: 27.3.0 jest-util: 27.3.1 dev: true @@ -4726,7 +4726,7 @@ packages: dependencies: '@jest/types': 27.2.5 '@types/graceful-fs': 4.1.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 anymatch: 3.1.2 fb-watchman: 2.0.1 graceful-fs: 4.2.8 @@ -4749,7 +4749,7 @@ packages: '@jest/source-map': 27.0.6 '@jest/test-result': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 chalk: 4.1.2 co: 4.6.0 expect: 27.3.1 @@ -4804,7 +4804,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 dev: true /jest-pnp-resolver/1.2.2_jest-resolve@27.3.1: @@ -4860,7 +4860,7 @@ packages: '@jest/test-result': 27.3.1 '@jest/transform': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 chalk: 4.1.2 emittery: 0.8.1 exit: 0.1.2 @@ -4922,7 +4922,7 @@ packages: resolution: {integrity: sha512-PtGdVK9EGC7dsaziskfqaAPib6wTViY3G8E5wz9tLVPhHyiDNTZn/xjZ4khAw+09QkoOVpn7vF5nPSN6dtBexA==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: - '@types/node': 16.11.2 + '@types/node': 16.11.4 graceful-fs: 4.2.8 dev: true @@ -4963,7 +4963,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 chalk: 4.1.2 ci-info: 3.2.0 graceful-fs: 4.2.8 @@ -4988,7 +4988,7 @@ packages: dependencies: '@jest/test-result': 27.3.1 '@jest/types': 27.2.5 - '@types/node': 16.11.2 + '@types/node': 16.11.4 ansi-escapes: 4.3.2 chalk: 4.1.2 jest-util: 27.3.1 @@ -4999,7 +4999,7 @@ packages: resolution: {integrity: sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 16.11.2 + '@types/node': 16.11.4 merge-stream: 2.0.0 supports-color: 7.2.0 dev: true @@ -5008,12 +5008,12 @@ packages: resolution: {integrity: sha512-ks3WCzsiZaOPJl/oMsDjaf0TRiSv7ctNgs0FqRr2nARsovz6AWWy4oLElwcquGSz692DzgZQrCLScPNs5YlC4g==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 16.11.2 + '@types/node': 16.11.4 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true - /jest/27.3.1_ts-node@10.3.1: + /jest/27.3.1_ts-node@10.4.0: resolution: {integrity: sha512-U2AX0AgQGd5EzMsiZpYt8HyZ+nSVIh5ujQ9CPp9EQZJMjXIiSZpJNweZl0swatKRoqHWgGKM3zaSwm4Zaz87ng==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} hasBin: true @@ -5023,9 +5023,9 @@ packages: node-notifier: optional: true dependencies: - '@jest/core': 27.3.1_ts-node@10.3.1 + '@jest/core': 27.3.1_ts-node@10.4.0 import-local: 3.0.3 - jest-cli: 27.3.1_ts-node@10.3.1 + jest-cli: 27.3.1_ts-node@10.4.0 transitivePeerDependencies: - bufferutil - canvas @@ -5206,7 +5206,7 @@ packages: dependencies: cli-truncate: 2.1.0 colorette: 1.4.0 - commander: 8.2.0 + commander: 8.3.0 cosmiconfig: 7.0.1 debug: 4.3.2_supports-color@8.1.1 enquirer: 2.3.6 @@ -6861,8 +6861,8 @@ packages: typescript: 4.4.4 dev: true - /ts-node/10.3.1_14436a5918f235eb1b9267bff073cfe7: - resolution: {integrity: sha512-Yw3W2mYzhHfCHOICGNJqa0i+rbL0rAyg7ZIHxU+K4pgY8gd2Lh1j+XbHCusJMykbj6RZMJVOY0MlHVd+GOivcw==} + /ts-node/10.4.0_bada05a3e1cd24c0fc5f82f6eaa2ca15: + resolution: {integrity: sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==} hasBin: true peerDependencies: '@swc/core': '>=1.2.50' @@ -6880,7 +6880,7 @@ packages: '@tsconfig/node12': 1.0.9 '@tsconfig/node14': 1.0.1 '@tsconfig/node16': 1.0.2 - '@types/node': 16.11.2 + '@types/node': 16.11.4 acorn: 8.5.0 acorn-walk: 8.2.0 arg: 4.1.3 @@ -6991,8 +6991,8 @@ packages: hasBin: true dev: true - /ua-parser-js/0.7.28: - resolution: {integrity: sha512-6Gurc1n//gjp9eQNXjD9O3M/sMwVtN5S8Lv9bvOYBfKfDNiIIhqiyi01vMBO45u4zkDE420w/e0se7Vs+sIg+g==} + /ua-parser-js/0.7.30: + resolution: {integrity: sha512-uXEtSresNUlXQ1QL4/3dQORcGv7+J2ookOG2ybA/ga9+HYEXueT2o+8dUJQkpedsyTyCJ6jCCirRcKtdtx1kbg==} dev: true /unicode-canonical-property-names-ecmascript/2.0.0: @@ -7346,7 +7346,7 @@ packages: dependencies: '@types/fs-extra': 9.0.13 '@types/minimist': 1.2.2 - '@types/node': 16.11.2 + '@types/node': 16.11.4 '@types/node-fetch': 2.5.12 chalk: 4.1.2 fs-extra: 10.0.0 diff --git a/src/drivers/children.ts b/src/drivers/children.ts index 328d36878b..d5105bd5fb 100644 --- a/src/drivers/children.ts +++ b/src/drivers/children.ts @@ -35,6 +35,8 @@ export const childrenDriver = ( newVNodeChildren![deltaPosition], oldVNodeChildren[deltaPosition], workStack, + undefined, + false, ); break; case VDeltaOperationTypes.DELETE: @@ -59,7 +61,14 @@ export const childrenDriver = ( // Interates backwards, so in case a childNode is destroyed, it will not shift the nodes // and break accessing by index for (let i = oldVNodeChildren.length - 1; i >= 0; --i) { - patch(el.childNodes[i], newVNodeChildren[i], oldVNodeChildren[i], workStack); + patch( + el.childNodes[i], + newVNodeChildren[i], + oldVNodeChildren[i], + workStack, + undefined, + true, + ); } } diff --git a/src/patch.ts b/src/patch.ts index dbcb3130e3..85779e6e59 100644 --- a/src/patch.ts +++ b/src/patch.ts @@ -25,12 +25,15 @@ export const compose = prevVNode?: VNode, workStack: VTask[] = [], commit?: VCommit, + isRoot = true, ): DOMNode => { const finish = (element: DOMNode): DOMNode => { - workStack.push(() => { - if (!prevVNode) element[OLD_VNODE_FIELD] = newVNode; - }); - flushWorkStack(workStack, commit); + if (isRoot) { + workStack.push(() => { + if (!prevVNode) element[OLD_VNODE_FIELD] = newVNode; + }); + flushWorkStack(workStack, commit); + } return element; }; From 74114dc5ea084be6801e9dda5bce6a7c656c2ced Mon Sep 17 00:00:00 2001 From: Aiden Bai Date: Fri, 22 Oct 2021 17:59:59 -0700 Subject: [PATCH 2/2] fix(patch): no extra parameter needed --- package.json | 2 +- pnpm-lock.yaml | 42 ++++++++++++++++++++--------------------- src/drivers/children.ts | 18 ++---------------- src/patch.ts | 11 ++++------- 4 files changed, 28 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 7df26804f4..246838f7a1 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "@typescript-eslint/eslint-plugin": "^5.1.0", "@typescript-eslint/parser": "^4.33.0", "benchmark": "^2.1.4", - "eslint": "^8.0.1", + "eslint": "^8.1.0", "eslint-config-prettier": "^8.3.0", "github-markdown-css": "^5.0.0", "glob": "^7.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8a249812c5..3e895c7649 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,7 +16,7 @@ specifiers: '@typescript-eslint/eslint-plugin': ^5.1.0 '@typescript-eslint/parser': ^4.33.0 benchmark: ^2.1.4 - eslint: ^8.0.1 + eslint: ^8.1.0 eslint-config-prettier: ^8.3.0 github-markdown-css: ^5.0.0 glob: ^7.2.0 @@ -52,11 +52,11 @@ devDependencies: '@types/glob': 7.2.0 '@types/jest': 27.0.2 '@types/node': 16.11.4 - '@typescript-eslint/eslint-plugin': 5.1.0_f127894afb221e47dc494017f42e8f05 - '@typescript-eslint/parser': 4.33.0_eslint@8.0.1+typescript@4.4.4 + '@typescript-eslint/eslint-plugin': 5.1.0_5d4085c5157e8c6edd78e10551a7fb5b + '@typescript-eslint/parser': 4.33.0_eslint@8.1.0+typescript@4.4.4 benchmark: 2.1.4 - eslint: 8.0.1 - eslint-config-prettier: 8.3.0_eslint@8.0.1 + eslint: 8.1.0 + eslint-config-prettier: 8.3.0_eslint@8.1.0 github-markdown-css: 5.0.0 glob: 7.2.0 husky: 7.0.4 @@ -2183,7 +2183,7 @@ packages: '@types/yargs-parser': 20.2.1 dev: true - /@typescript-eslint/eslint-plugin/5.1.0_f127894afb221e47dc494017f42e8f05: + /@typescript-eslint/eslint-plugin/5.1.0_5d4085c5157e8c6edd78e10551a7fb5b: resolution: {integrity: sha512-bekODL3Tqf36Yz8u+ilha4zGxL9mdB6LIsIoMAvvC5FAuWo4NpZYXtCbv7B2CeR1LhI/lLtLk+q4tbtxuoVuCg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2194,11 +2194,11 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/experimental-utils': 5.1.0_eslint@8.0.1+typescript@4.4.4 - '@typescript-eslint/parser': 4.33.0_eslint@8.0.1+typescript@4.4.4 + '@typescript-eslint/experimental-utils': 5.1.0_eslint@8.1.0+typescript@4.4.4 + '@typescript-eslint/parser': 4.33.0_eslint@8.1.0+typescript@4.4.4 '@typescript-eslint/scope-manager': 5.1.0 debug: 4.3.2 - eslint: 8.0.1 + eslint: 8.1.0 functional-red-black-tree: 1.0.1 ignore: 5.1.8 regexpp: 3.2.0 @@ -2209,7 +2209,7 @@ packages: - supports-color dev: true - /@typescript-eslint/experimental-utils/5.1.0_eslint@8.0.1+typescript@4.4.4: + /@typescript-eslint/experimental-utils/5.1.0_eslint@8.1.0+typescript@4.4.4: resolution: {integrity: sha512-ovE9qUiZMOMgxQAESZsdBT+EXIfx/YUYAbwGUI6V03amFdOOxI9c6kitkgRvLkJaLusgMZ2xBhss+tQ0Y1HWxA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2219,15 +2219,15 @@ packages: '@typescript-eslint/scope-manager': 5.1.0 '@typescript-eslint/types': 5.1.0 '@typescript-eslint/typescript-estree': 5.1.0_typescript@4.4.4 - eslint: 8.0.1 + eslint: 8.1.0 eslint-scope: 5.1.1 - eslint-utils: 3.0.0_eslint@8.0.1 + eslint-utils: 3.0.0_eslint@8.1.0 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/parser/4.33.0_eslint@8.0.1+typescript@4.4.4: + /@typescript-eslint/parser/4.33.0_eslint@8.1.0+typescript@4.4.4: resolution: {integrity: sha512-ZohdsbXadjGBSK0/r+d87X0SBmKzOq4/S5nzK6SBgJspFo9/CUDJ7hjayuze+JK7CZQLDMroqytp7pOcFKTxZA==} engines: {node: ^10.12.0 || >=12.0.0} peerDependencies: @@ -2241,7 +2241,7 @@ packages: '@typescript-eslint/types': 4.33.0 '@typescript-eslint/typescript-estree': 4.33.0_typescript@4.4.4 debug: 4.3.2 - eslint: 8.0.1 + eslint: 8.1.0 typescript: 4.4.4 transitivePeerDependencies: - supports-color @@ -3584,13 +3584,13 @@ packages: source-map: 0.6.1 dev: true - /eslint-config-prettier/8.3.0_eslint@8.0.1: + /eslint-config-prettier/8.3.0_eslint@8.1.0: resolution: {integrity: sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.0.1 + eslint: 8.1.0 dev: true /eslint-scope/5.1.1: @@ -3616,13 +3616,13 @@ packages: eslint-visitor-keys: 1.3.0 dev: true - /eslint-utils/3.0.0_eslint@8.0.1: + /eslint-utils/3.0.0_eslint@8.1.0: resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} peerDependencies: eslint: '>=5' dependencies: - eslint: 8.0.1 + eslint: 8.1.0 eslint-visitor-keys: 2.1.0 dev: true @@ -3690,8 +3690,8 @@ packages: - supports-color dev: true - /eslint/8.0.1: - resolution: {integrity: sha512-LsgcwZgQ72vZ+SMp4K6pAnk2yFDWL7Ti4pJaRvsZ0Hsw2h8ZjUIW38a9AFn2cZXdBMlScMFYYgsSp4ttFI/0bA==} + /eslint/8.1.0: + resolution: {integrity: sha512-JZvNneArGSUsluHWJ8g8MMs3CfIEzwaLx9KyH4tZ2i+R2/rPWzL8c0zg3rHdwYVpN/1sB9gqnjHwz9HoeJpGHw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: @@ -3705,7 +3705,7 @@ packages: enquirer: 2.3.6 escape-string-regexp: 4.0.0 eslint-scope: 6.0.0 - eslint-utils: 3.0.0_eslint@8.0.1 + eslint-utils: 3.0.0_eslint@8.1.0 eslint-visitor-keys: 3.0.0 espree: 9.0.0 esquery: 1.4.0 diff --git a/src/drivers/children.ts b/src/drivers/children.ts index d5105bd5fb..83f7abfd1e 100644 --- a/src/drivers/children.ts +++ b/src/drivers/children.ts @@ -30,14 +30,7 @@ export const childrenDriver = ( ); break; case VDeltaOperationTypes.UPDATE: - patch( - child, - newVNodeChildren![deltaPosition], - oldVNodeChildren[deltaPosition], - workStack, - undefined, - false, - ); + patch(child, newVNodeChildren![deltaPosition], oldVNodeChildren[deltaPosition]); break; case VDeltaOperationTypes.DELETE: workStack.push(() => el.removeChild(child)); @@ -61,14 +54,7 @@ export const childrenDriver = ( // Interates backwards, so in case a childNode is destroyed, it will not shift the nodes // and break accessing by index for (let i = oldVNodeChildren.length - 1; i >= 0; --i) { - patch( - el.childNodes[i], - newVNodeChildren[i], - oldVNodeChildren[i], - workStack, - undefined, - true, - ); + patch(el.childNodes[i], newVNodeChildren[i], oldVNodeChildren[i]); } } diff --git a/src/patch.ts b/src/patch.ts index 85779e6e59..dbcb3130e3 100644 --- a/src/patch.ts +++ b/src/patch.ts @@ -25,15 +25,12 @@ export const compose = prevVNode?: VNode, workStack: VTask[] = [], commit?: VCommit, - isRoot = true, ): DOMNode => { const finish = (element: DOMNode): DOMNode => { - if (isRoot) { - workStack.push(() => { - if (!prevVNode) element[OLD_VNODE_FIELD] = newVNode; - }); - flushWorkStack(workStack, commit); - } + workStack.push(() => { + if (!prevVNode) element[OLD_VNODE_FIELD] = newVNode; + }); + flushWorkStack(workStack, commit); return element; };