Skip to content

fix(runtime-core): inherit comment nodes during block patch in production build #10748

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

Merged
merged 7 commits into from
May 13, 2025

Conversation

tonliver
Copy link
Contributor

@tonliver tonliver commented Apr 20, 2024

close #10747
close #12650

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of comment nodes within teleports to ensure they are correctly preserved and managed during updates and unmounting, including in optimized mode.
  • Tests
    • Added new tests to verify correct behavior of comment nodes in teleports, covering edge cases related to DOM structure and node identity.

@tonliver tonliver changed the title fix #10747 fix(runtime-core): TypeError when using html comment in teleport[fix #10747] Apr 20, 2024
Copy link

netlify bot commented Apr 20, 2024

Deploy Preview for vue-sfc-playground failed.

Name Link
🔨 Latest commit 46f6f3b
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/66231674bd858b000859c462

Copy link

netlify bot commented Apr 20, 2024

Deploy Preview for vue-next-template-explorer failed.

Name Link
🔨 Latest commit 46f6f3b
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/662316740aee4500083b5a0e

@tonliver tonliver changed the title fix(runtime-core): TypeError when using html comment in teleport[fix #10747] fix(runtime-core): TypeError when using html comment in teleport(fix #10747) Apr 20, 2024
@tonliver tonliver force-pushed the fix/teleport-comment branch from 46f6f3b to 8e82e54 Compare April 20, 2024 01:43
@tonliver
Copy link
Contributor Author

@edison1105 I think assuming that all comments should be removed in production mode, then there shouldn't create vnodes for comments in production mode for performance reason. However, comment vnodes are created, also removed by nodeOpt.remove method during unmounting, except for traversStaticChildren, which lacks consistency. Indeed this inconsistency in handling caused the exception.

@edison1105
Copy link
Member

@tonliver Could you add a test case?

@edison1105 edison1105 added the need test The PR has missing test cases. label Apr 24, 2024
@tonliver
Copy link
Contributor Author

@tonliver Could you add a test case?

Sure, I'll work on it as soon as possible.

Copy link

github-actions bot commented May 6, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB (+31 B) 38.2 kB (+9 B) 34.4 kB (-11 B)
vue.global.prod.js 159 kB (+31 B) 58.4 kB (+7 B) 51.9 kB (+19 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.6 kB (+31 B) 18.2 kB (+11 B) 16.7 kB (+15 B)
createApp 54.5 kB (+31 B) 21.2 kB (+11 B) 19.4 kB (+23 B)
createSSRApp 58.7 kB (+31 B) 23 kB (+9 B) 20.9 kB (+10 B)
defineCustomElement 59.3 kB (+31 B) 22.8 kB (+12 B) 20.8 kB (-2 B)
overall 68.6 kB (+31 B) 26.4 kB (+9 B) 24 kB (+46 B)

@tonliver
Copy link
Contributor Author

@edison1105 I've added some test cases.

@tonliver
Copy link
Contributor Author

@edison1105 What else can I do?

@tonliver
Copy link
Contributor Author

@yyx990803 What else can I do?

@haoqunjiang haoqunjiang added scope: teleport 🔩 p2-edge-case and removed need test The PR has missing test cases. labels May 27, 2024
@edison1105 edison1105 added the ready for review This PR requires more reviews label Oct 22, 2024
@edison1105 edison1105 added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. and removed 🔩 p2-edge-case labels Jan 6, 2025
Copy link

pkg-pr-new bot commented Jan 6, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@10748

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@10748

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@10748

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@10748

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@10748

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@10748

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@10748

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@10748

@vue/shared

npm i https://pkg.pr.new/@vue/shared@10748

vue

npm i https://pkg.pr.new/vue@10748

@vue/compat

npm i https://pkg.pr.new/@vue/compat@10748

commit: d0d0b16

@edison1105 edison1105 changed the title fix(runtime-core): TypeError when using html comment in teleport(fix #10747) fix(runtime-core): inherit comment nodes during block patch in production build Jan 6, 2025
@edison1105 edison1105 changed the title fix(runtime-core): inherit comment nodes during block patch in production build fix(runtime-core): inherit comment nodes during block patch in production build Jan 7, 2025
Copy link

coderabbitai bot commented May 13, 2025

"""

Walkthrough

The changes add new test cases to the Teleport component's test suite, specifically targeting scenarios with comment nodes as teleport children. Additionally, the renderer logic for handling comment vnode .el assignments is adjusted to apply in all environments, not just development, addressing issues with teleport unmounting and updates in production mode.

Changes

File(s) Change Summary
packages/runtime-core/__tests__/components/Teleport.spec.ts Added two tests for teleport behavior with top-level comment nodes, covering updates and unmounting.
packages/runtime-core/src/renderer.ts Removed __DEV__ guard around comment vnode .el assignment in traverseStaticChildren.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Teleport Test Suite
    participant Renderer as Renderer
    participant DOM as DOM

    Test->>Renderer: Mount teleport with comment node
    Renderer->>DOM: Insert comment node into teleport target
    Test->>Renderer: Trigger reactive update
    Renderer->>DOM: Ensure comment node instance is preserved
    Test->>Renderer: Unmount teleport
    Renderer->>DOM: Remove comment node from DOM
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent TypeError when teleport's top-level child is a comment node and ensure proper unmounting (#10747)
Ensure correct handling of comment nodes in teleports during updates and unmounts in production mode (#12650)

Poem

A teleport hops with a comment in tow,
Through updates and changes, it’s ready to go!
No more TypeErrors, no DOM in despair,
Comment nodes handled with utmost care.
With every new test, the bugs disappear—
🐇 The code hops forward, with nothing to fear!
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75a43ea and d0d0b16.

📒 Files selected for processing (1)
  • packages/runtime-core/src/renderer.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/runtime-core/src/renderer.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@edison1105
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented May 13, 2025

📝 Ran ecosystem CI: Open

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

@edison1105 edison1105 merged commit 6264505 into vuejs:main May 13, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready for review This PR requires more reviews scope: teleport
Projects
None yet
4 participants