core
core copied to clipboard
fix(runtime-core): TypeError when using html comment in teleport(fix #10747)
close #10747
Deploy Preview for vue-sfc-playground failed.
| Name | Link |
|---|---|
| Latest commit | 46f6f3b162580acd7026248ee1c5cf1ff3d6faf6 |
| Latest deploy log | https://app.netlify.com/sites/vue-sfc-playground/deploys/66231674bd858b000859c462 |
Deploy Preview for vue-next-template-explorer failed.
| Name | Link |
|---|---|
| Latest commit | 46f6f3b162580acd7026248ee1c5cf1ff3d6faf6 |
| Latest deploy log | https://app.netlify.com/sites/vue-next-template-explorer/deploys/662316740aee4500083b5a0e |
@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.
@tonliver Could you add a test case?
@tonliver Could you add a test case?
Sure, I'll work on it as soon as possible.
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) |
@edison1105 I've added some test cases.
@edison1105 What else can I do?
@yyx990803 What else can I do?
@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
"""
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
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 75a43ea106019f01fbc75108518eeb462d0101db and d0d0b16701afe374d209f0844be940d8f4349a06.
π 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
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
/ecosystem-ci run
π Ran ecosystem CI: Open
| suite | result | latest scheduled |
|---|---|---|
| nuxt | :white_check_mark: success | :white_check_mark: success |
| quasar | :white_check_mark: success | :white_check_mark: success |
| router | :white_check_mark: success | :white_check_mark: success |
| pinia | :x: failure | :white_check_mark: success |
| language-tools | :x: failure | :white_check_mark: success |
| primevue | :x: failure | :white_check_mark: success |
| radix-vue | :white_check_mark: success | :white_check_mark: success |
| test-utils | :white_check_mark: success | :white_check_mark: success |
| vueuse | :white_check_mark: success | :white_check_mark: success |
| vue-simple-compiler | :white_check_mark: success | :white_check_mark: success |
| vue-macros | :white_check_mark: success | :white_check_mark: success |
| vant | :white_check_mark: success | :white_check_mark: success |
| vitepress | :white_check_mark: success | :white_check_mark: success |
| vite-plugin-vue | :white_check_mark: success | :white_check_mark: success |
| vue-i18n | :white_check_mark: success | :white_check_mark: success |
| vuetify | :white_check_mark: success | :white_check_mark: success |