Repository navigation
fix(hydration): preserve namespace when patching dynamic props - #15086
edison1105 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughHydration now derives SVG/MathML namespaces and passes them to ChangesHydration namespace handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/runtime-core/__tests__/hydration.spec.ts (1)
2763-2787: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the MathML half of the namespace contract.
This regression only exercises SVG, while the production change also introduces a
'mathml'namespace path. Add a dynamic MathML-property case, or confirm equivalent coverage elsewhere, so regressions in that path cannot pass unnoticed.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/runtime-core/__tests__/hydration.spec.ts` around lines 2763 - 2787, Extend the hydration coverage in the test around “patches dynamic props as attributes on SVG elements” with an equivalent dynamic MathML element/property case. Verify the MathML namespace path patches the changed property as an attribute and emits no failed-property warning, matching the existing SVG assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/runtime-core/src/hydration.ts`:
- Around line 494-498: Update the downstream patching contract in patchProp to
recognize namespace === 'mathml' and route MathML properties through
setAttribute-based handling, while leaving the existing namespace === 'svg'
behavior unchanged. Add a regression test covering dynamic MathML property
hydration and verify it uses attribute patching rather than normal DOM-property
detection.
---
Nitpick comments:
In `@packages/runtime-core/__tests__/hydration.spec.ts`:
- Around line 2763-2787: Extend the hydration coverage in the test around
“patches dynamic props as attributes on SVG elements” with an equivalent dynamic
MathML element/property case. Verify the MathML namespace path patches the
changed property as an attribute and emits no failed-property warning, matching
the existing SVG assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2e6a9408-2d17-4562-9e01-9c3247557b3c
📒 Files selected for processing (2)
packages/runtime-core/__tests__/hydration.spec.tspackages/runtime-core/src/hydration.ts
| const namespace = el.namespaceURI!.includes('svg') | ||
| ? 'svg' | ||
| : el.namespaceURI!.includes('MathML') | ||
| ? 'mathml' | ||
| : undefined |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Ensure MathML is handled by the downstream attribute path.
This sets namespace to 'mathml', but packages/runtime-dom/src/patchProp.ts currently derives isSVG only for namespace === 'svg'. MathML hydration therefore still uses normal DOM-property detection instead of reliably patching dynamic props with setAttribute, leaving the MathML half of the stated fix unresolved.
Update the downstream patching contract to explicitly route MathML properties through attribute handling while preserving SVG-specific behavior, and add a MathML regression test.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/runtime-core/src/hydration.ts` around lines 494 - 498, Update the
downstream patching contract in patchProp to recognize namespace === 'mathml'
and route MathML properties through setAttribute-based handling, while leaving
the existing namespace === 'svg' behavior unchanged. Add a regression test
covering dynamic MathML property hydration and verify it uses attribute patching
rather than normal DOM-property detection.
close #15081
Summary by CodeRabbit
viewBoxare correctly applied as attributes during hydration.