Skip to content

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Apr 21, 2025

Compiler Changes

  • Compiler-vapor:
    • Adjusted the timing of child/nthChild/next calls when a setInsertionState call is present, ensuring they execute sequentially rather than entirely before setInsertionState (reverting fix(compiler-vapor): move next, child and nthChild before setInsertionState #13057).
    • Modified the anchor handling for setInsertionState. For append scenarios, the anchor now has two possible values:
      • null: Indicates that there are no nodes before the dynamic node to be appended.
      • A number greater than 0: Represents the count of static nodes preceding it (used for node positioning during hydration).

Runtime Changes

  • Hydration-Aware APIs (@vue/runtime-vapor):

    • Since the insertion of dynamic nodes may affect the childNodes under the insertionParent, which could cause the nodes returned by child/nthChild/next to shift, we need to create a backup copy of insertionParent.childNodes when executing setInsertionState. The child/nthChild/next operations should then perform lookups on this backed-up childNodes.
    • Runtime functions like createIf, createFor, createDynamicComponent, and createSlot are now hydration-aware.
  • DOM Traversal (@vue/runtime-vapor/dom):

    • Introduced hydration-specific implementations for DOM traversal helpers (__child, __next, __nthChild, __txt). These versions skip over the dynamic node to correctly locate the target nodes for hydration.

    • Added enableHydrationNodeHelper and disableHydrationNodeHelper to switch between standard and hydration-specific traversal logic.

    • see benchmark for direct function call vs delegated function call

      benchmark result
      benchmark                   avg (min … max) p75 / p99    (min … top 1%)
      ------------------------------------------- -------------------------------
      direct function call         534.76 ps/iter   1.22 ns █                     !
                             (0.00 ps … 19.53 ns)   2.44 ns █         █          
                          (  0.00  b …   0.00  b)   0.00  b █▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁
      
      impl function call           536.44 ps/iter   1.22 ns █                     !
                             (0.00 ps … 21.97 ns)   2.44 ns █         █          
                          (  0.00  b …   0.00  b)   0.00  b █▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁
      
      summary
        direct function call
         1x faster than impl function call
  • Core Runtime (@vue/runtime-core):

    • Enhanced the existing hydration.ts to recognize and correctly handle the hydration of Vapor components within VDOM components.
  • VDOM Interop (@vue/runtime-vapor/vdomInterop.ts):

    • Updated the interop plugin to support hydration when mixing VDOM and Vapor components. Ensures that VDOM components rendered within Vapor contexts, and vice-versa, are correctly hydrated.

Tests

  • Hydration Tests (runtime-vapor/__tests__/hydration.spec.ts):
    • Added extensive tests specifically for Vapor mode hydration, covering:
      • Basic text and element hydration.
      • Hydration of components (including fragment components, dynamic components).
      • Control flow directives (v-if, v-for).
      • slots and dynamic components (<component :is="...">).
      • VDOM interop hydration scenarios.
      • mismatch handling
      • data-allow-mismatch

Copy link

coderabbitai bot commented Apr 21, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch edison/feat/vaporHydration

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

netlify bot commented Apr 21, 2025

Deploy Preview for vapor-repl ready!

Name Link
🔨 Latest commit 0ca32f4
🔍 Latest deploy log https://app.netlify.com/projects/vapor-repl/deploys/6867420c316c91000855dc27
😎 Deploy Preview https://deploy-preview-13226--vapor-repl.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

pkg-pr-new bot commented Apr 21, 2025

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/compiler-vapor

npm i https://pkg.pr.new/@vue/compiler-vapor@13226

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/runtime-vapor

npm i https://pkg.pr.new/@vue/runtime-vapor@13226

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: ac11bd0

@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from e704d07 to 58cd7db Compare April 21, 2025 08:09
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch 3 times, most recently from 16c91ca to 287700c Compare April 22, 2025 09:44
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch 2 times, most recently from 9b7e68d to 03bf24c Compare April 22, 2025 13:29
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from 03bf24c to d8443d3 Compare April 22, 2025 13:34
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch 2 times, most recently from 0cf3a63 to 86f0746 Compare April 23, 2025 07:59
@edison1105 edison1105 changed the title feat(hydration): handle component with anchor insertion feat(vapor): hydration Apr 23, 2025
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from 86f0746 to 25b8fbe Compare April 23, 2025 08:16
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from b0852aa to 3e7f093 Compare April 23, 2025 09:44
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from e26120f to 04eadd8 Compare April 23, 2025 14:42
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from 9f0a509 to b5762b5 Compare April 24, 2025 01:59
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from 027b019 to e9c9e49 Compare April 24, 2025 14:12
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from 66bca69 to e4fcb9d Compare August 20, 2025 05:58
Copy link

netlify bot commented Aug 21, 2025

Deploy Preview for vue-sfc-playground failed. Why did it fail? →

Name Link
🔨 Latest commit 29692d9
🔍 Latest deploy log https://app.netlify.com/projects/vue-sfc-playground/deploys/68a725493b086b000851b8fb

@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from a9a643e to 41d322e Compare September 9, 2025 07:35
@edison1105 edison1105 force-pushed the edison/feat/vaporHydration branch from 37cee48 to df2c42a Compare September 10, 2025 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope:hydration scope: vapor related to vapor mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants