Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): properly diff slot node and fallback node #9213

Closed
wants to merge 20 commits into from

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Sep 14, 2023

close #9200
close #9308
close #7256

note:
Both slot fallback and slot nodes are stable fragments but can not take the fast path.

solution:

  • always unmount the old vnode and mount the new one.

@github-actions
Copy link

github-actions bot commented Sep 14, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 90.7 kB (+66 B) 34.5 kB (+25 B) 31.1 kB
vue.global.prod.js 148 kB (+66 B) 53.8 kB (+21 B) 48 kB (-38 B)

Usages

Name Size Gzip Brotli
createApp 50.8 kB (+54 B) 19.9 kB (+21 B) 18.1 kB (+22 B)
createSSRApp 54.2 kB (+54 B) 21.2 kB (+20 B) 19.3 kB (+17 B)
defineCustomElement 53.1 kB (+54 B) 20.6 kB (+20 B) 18.8 kB (+28 B)
overall 64.5 kB (+54 B) 24.9 kB (+24 B) 22.5 kB (-31 B)

@edison1105 edison1105 changed the title fix(runtime-core): avoid tracking slot fallback node as block fix(runtime-core): force full diff slot and fallback nodes Sep 29, 2023
test: add test case

chore: improve code

chore: update test

chore: update test
@edison1105
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Apr 16, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success
nuxt success success
pinia success failure
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify failure success
vueuse success success
vue-simple-compiler success success

Copy link
Contributor

@skirtles-code skirtles-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether we should completely avoid slot content being paired against fallback content in the diff? I don't think users expect elements/components to be reused in this way and it seems bug prone.

Consider this example:

A similar example using a stateful child component:

@edison1105 edison1105 changed the title fix(runtime-core): force full diff slot and fallback nodes fix(runtime-core): properly diff slot node and fallback node Jun 10, 2024
Comment on lines 41 to 48
const vnode = createVNode(
'slot',
props,
fallback && fallback(),
fallback ? PatchFlags.BAIL : undefined,
)
vnode.isSlotFallback = !!fallback
return vnode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this part of the change. For custom elements, wouldn't switching between the slot content and the fallback be handled natively by the browser, rather than by the renderer? The presence of a fallback doesn't necessarily mean that it is being shown in the component, we render it inside the native <slot> either way and let the browser do the rest.

If this is needed then there should probably be a test for it. It seems that the current tests pass even without this change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@edison1105
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Jun 22, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success failure
nuxt success success
pinia success success
primevue success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant failure success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@jh-leong jh-leong mentioned this pull request Jul 4, 2024
@yyx990803 yyx990803 closed this in d76dd9c Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Rejected
6 participants