core icon indicating copy to clipboard operation
core copied to clipboard

fix(runtime-core): TypeError when using html comment in teleport(fix #10747)

Open tonliver opened this issue 1 year ago β€’ 9 comments

close #10747

tonliver avatar Apr 20 '24 01:04 tonliver

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

netlify[bot] avatar Apr 20 '24 01:04 netlify[bot]

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

netlify[bot] avatar Apr 20 '24 01:04 netlify[bot]

@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 avatar Apr 23 '24 14:04 tonliver

@tonliver Could you add a test case?

edison1105 avatar Apr 24 '24 01:04 edison1105

@tonliver Could you add a test case?

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

tonliver avatar Apr 24 '24 02:04 tonliver

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)

github-actions[bot] avatar May 06 '24 22:05 github-actions[bot]

@edison1105 I've added some test cases.

tonliver avatar May 13 '24 10:05 tonliver

@edison1105 What else can I do?

tonliver avatar May 15 '24 13:05 tonliver

@yyx990803 What else can I do?

tonliver avatar May 27 '24 10:05 tonliver

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

pkg-pr-new[bot] avatar Jan 06 '25 13:01 pkg-pr-new[bot]

"""

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 @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.

coderabbitai[bot] avatar May 13 '25 13:05 coderabbitai[bot]

/ecosystem-ci run

edison1105 avatar May 13 '25 13:05 edison1105

πŸ“ 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

vue-bot avatar May 13 '25 14:05 vue-bot