diff --git a/package.json b/package.json index e29355349a..4530c915d6 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "@types/glob": "^7.2.0", "@types/jest": "^27.0.2", "@types/node": "^16.11.6", - "@typescript-eslint/eslint-plugin": "^5.2.0", + "@typescript-eslint/eslint-plugin": "^5.3.0", "@typescript-eslint/parser": "^4.33.0", "benchmark": "^2.1.4", "eslint": "^8.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 66207e4ff6..d39e376224 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ specifiers: '@types/glob': ^7.2.0 '@types/jest': ^27.0.2 '@types/node': ^16.11.6 - '@typescript-eslint/eslint-plugin': ^5.2.0 + '@typescript-eslint/eslint-plugin': ^5.3.0 '@typescript-eslint/parser': ^4.33.0 benchmark: ^2.1.4 eslint: ^8.1.0 @@ -52,7 +52,7 @@ devDependencies: '@types/glob': 7.2.0 '@types/jest': 27.0.2 '@types/node': 16.11.6 - '@typescript-eslint/eslint-plugin': 5.2.0_5d4085c5157e8c6edd78e10551a7fb5b + '@typescript-eslint/eslint-plugin': 5.3.0_5d4085c5157e8c6edd78e10551a7fb5b '@typescript-eslint/parser': 4.33.0_eslint@8.1.0+typescript@4.4.4 benchmark: 2.1.4 eslint: 8.1.0 @@ -2333,8 +2333,8 @@ packages: '@types/yargs-parser': 20.2.1 dev: true - /@typescript-eslint/eslint-plugin/5.2.0_5d4085c5157e8c6edd78e10551a7fb5b: - resolution: {integrity: sha512-qQwg7sqYkBF4CIQSyRQyqsYvP+g/J0To9ZPVNJpfxfekl5RmdvQnFFTVVwpRtaUDFNvjfe/34TgY/dpc3MgNTw==} + /@typescript-eslint/eslint-plugin/5.3.0_5d4085c5157e8c6edd78e10551a7fb5b: + resolution: {integrity: sha512-ARUEJHJrq85aaiCqez7SANeahDsJTD3AEua34EoQN9pHS6S5Bq9emcIaGGySt/4X2zSi+vF5hAH52sEen7IO7g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: '@typescript-eslint/parser': ^5.0.0 @@ -2344,9 +2344,9 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/experimental-utils': 5.2.0_eslint@8.1.0+typescript@4.4.4 + '@typescript-eslint/experimental-utils': 5.3.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.2.0 + '@typescript-eslint/scope-manager': 5.3.0 debug: 4.3.2 eslint: 8.1.0 functional-red-black-tree: 1.0.1 @@ -2359,16 +2359,16 @@ packages: - supports-color dev: true - /@typescript-eslint/experimental-utils/5.2.0_eslint@8.1.0+typescript@4.4.4: - resolution: {integrity: sha512-fWyT3Agf7n7HuZZRpvUYdFYbPk3iDCq6fgu3ulia4c7yxmPnwVBovdSOX7RL+k8u6hLbrXcdAehlWUVpGh6IEw==} + /@typescript-eslint/experimental-utils/5.3.0_eslint@8.1.0+typescript@4.4.4: + resolution: {integrity: sha512-NFVxYTjKj69qB0FM+piah1x3G/63WB8vCBMnlnEHUsiLzXSTWb9FmFn36FD9Zb4APKBLY3xRArOGSMQkuzTF1w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: '*' dependencies: '@types/json-schema': 7.0.9 - '@typescript-eslint/scope-manager': 5.2.0 - '@typescript-eslint/types': 5.2.0 - '@typescript-eslint/typescript-estree': 5.2.0_typescript@4.4.4 + '@typescript-eslint/scope-manager': 5.3.0 + '@typescript-eslint/types': 5.3.0 + '@typescript-eslint/typescript-estree': 5.3.0_typescript@4.4.4 eslint: 8.1.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0_eslint@8.1.0 @@ -2405,12 +2405,12 @@ packages: '@typescript-eslint/visitor-keys': 4.33.0 dev: true - /@typescript-eslint/scope-manager/5.2.0: - resolution: {integrity: sha512-RW+wowZqPzQw8MUFltfKYZfKXqA2qgyi6oi/31J1zfXJRpOn6tCaZtd9b5u9ubnDG2n/EMvQLeZrsLNPpaUiFQ==} + /@typescript-eslint/scope-manager/5.3.0: + resolution: {integrity: sha512-22Uic9oRlTsPppy5Tcwfj+QET5RWEnZ5414Prby465XxQrQFZ6nnm5KnXgnsAJefG4hEgMnaxTB3kNEyjdjj6A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.2.0 - '@typescript-eslint/visitor-keys': 5.2.0 + '@typescript-eslint/types': 5.3.0 + '@typescript-eslint/visitor-keys': 5.3.0 dev: true /@typescript-eslint/types/4.33.0: @@ -2418,8 +2418,8 @@ packages: engines: {node: ^8.10.0 || ^10.13.0 || >=11.10.1} dev: true - /@typescript-eslint/types/5.2.0: - resolution: {integrity: sha512-cTk6x08qqosps6sPyP2j7NxyFPlCNsJwSDasqPNjEQ8JMD5xxj2NHxcLin5AJQ8pAVwpQ8BMI3bTxR0zxmK9qQ==} + /@typescript-eslint/types/5.3.0: + resolution: {integrity: sha512-fce5pG41/w8O6ahQEhXmMV+xuh4+GayzqEogN24EK+vECA3I6pUwKuLi5QbXO721EMitpQne5VKXofPonYlAQg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true @@ -2444,8 +2444,8 @@ packages: - supports-color dev: true - /@typescript-eslint/typescript-estree/5.2.0_typescript@4.4.4: - resolution: {integrity: sha512-RsdXq2XmVgKbm9nLsE3mjNUM7BTr/K4DYR9WfFVMUuozHWtH5gMpiNZmtrMG8GR385EOSQ3kC9HiEMJWimxd/g==} + /@typescript-eslint/typescript-estree/5.3.0_typescript@4.4.4: + resolution: {integrity: sha512-FJ0nqcaUOpn/6Z4Jwbtf+o0valjBLkqc3MWkMvrhA2TvzFXtcclIM8F4MBEmYa2kgcI8EZeSAzwoSrIC8JYkug==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: typescript: '*' @@ -2453,8 +2453,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 5.2.0 - '@typescript-eslint/visitor-keys': 5.2.0 + '@typescript-eslint/types': 5.3.0 + '@typescript-eslint/visitor-keys': 5.3.0 debug: 4.3.2 globby: 11.0.4 is-glob: 4.0.3 @@ -2473,11 +2473,11 @@ packages: eslint-visitor-keys: 2.1.0 dev: true - /@typescript-eslint/visitor-keys/5.2.0: - resolution: {integrity: sha512-Nk7HizaXWWCUBfLA/rPNKMzXzWS8Wg9qHMuGtT+v2/YpPij4nVXrVJc24N/r5WrrmqK31jCrZxeHqIgqRzs0Xg==} + /@typescript-eslint/visitor-keys/5.3.0: + resolution: {integrity: sha512-oVIAfIQuq0x2TFDNLVavUn548WL+7hdhxYn+9j3YdJJXB7mH9dAmZNJsPDa7Jc+B9WGqoiex7GUDbyMxV0a/aw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - '@typescript-eslint/types': 5.2.0 + '@typescript-eslint/types': 5.3.0 eslint-visitor-keys: 3.0.0 dev: true diff --git a/src/__test__/patch.test.ts b/src/__test__/patch.test.ts index 4fa8e88b4d..21618ee13e 100644 --- a/src/__test__/patch.test.ts +++ b/src/__test__/patch.test.ts @@ -212,11 +212,4 @@ describe('.patch', () => { expect(el2).toEqual(document.createElement('a')); }); - - it('should return el if ignore is set', () => { - const el1 = createElement(m('div', { ignore: true })); - const el2 = patch(el1, m('a')); - - expect(el2).toEqual(el1); - }); }); diff --git a/src/drivers/children.ts b/src/drivers/children.ts index 62ae25f639..3d57e518ae 100644 --- a/src/drivers/children.ts +++ b/src/drivers/children.ts @@ -30,6 +30,13 @@ export const childrenDriver = workStack, }; + if (newVNode.flag === VFlags.IGNORE_NODE) return data; + + if (newVNode.flag === VFlags.REPLACE_NODE) { + el.replaceWith(createElement(newVNode)); + return data; + } + const oldVNodeChildren: VNode[] = oldVNode?.children ?? []; const newVNodeChildren: VNode[] | undefined = newVNode.children; const delta: VDelta | undefined = newVNode.delta; diff --git a/src/patch.ts b/src/patch.ts index c95c0f8d76..7f9fb32361 100644 --- a/src/patch.ts +++ b/src/patch.ts @@ -53,7 +53,6 @@ export const compose = if (!hasString) { const oldVElement = prevVNode; const newVElement = newVNode; - if (oldVElement?.props?.ignore || newVElement?.props?.ignore) return finish(el); if ( (oldVElement?.key === undefined && newVElement?.key === undefined) || oldVElement?.key !== newVElement?.key diff --git a/src/types/base.ts b/src/types/base.ts index c9d237aef0..7136653920 100644 --- a/src/types/base.ts +++ b/src/types/base.ts @@ -36,6 +36,8 @@ export enum VFlags { ONLY_TEXT_CHILDREN = 1, ONLY_KEYED_CHILDREN = 2, ANY_CHILDREN = 3, + REPLACE_NODE = 4, + IGNORE_NODE = 5, } export const enum VDeltaOperationTypes {