Repository navigation
fix(compiler-vapor): pass a static style to components as an object like vdom - #15745
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Size ReportBundles
Usages
|
…ike vdom
A static `style` written on a component reached it as the raw CSS string, so
`$attrs.style` was a string while the vdom compiler passes an object
(`transformStyle` -> `parseStringStyle` -> `JSON.stringify`). A child merging
it (`{ ...$attrs.style, color: 'red' }`) then got character indices instead of
style properties.
Emit `_normalizeStyle(["<css>"])` instead of parsing the CSS in the compiler:
`normalizeStyle` parses the strings of a style array, so vue's own parser
produces the object at runtime and the compiler needs no copy of it. The
runtime memoizes prop getters in a computed, so the parse happens once per
component instance and only when `style` is read.
Plain elements keep the string (it is baked into the template) and so do
custom elements, which compile to `createPlainElement` -- matching the
upstream gate on `ElementTypes.COMPONENT`.
Merged from vuejs/core#15745
…ike vdom
A static `style` written on a component reached it as the raw CSS string, so
`$attrs.style` was a string while the vdom compiler passes an object
(`transformStyle` -> `parseStringStyle` -> `JSON.stringify`). A child merging
it (`{ ...$attrs.style, color: 'red' }`) then got character indices instead of
style properties.
Emit `_normalizeStyle(["<css>"])` instead of parsing the CSS in the compiler:
`normalizeStyle` parses the strings of a style array, so vue's own parser
produces the object at runtime and the compiler needs no copy of it. The
runtime memoizes prop getters in a computed, so the parse happens once per
component instance and only when `style` is read.
Plain elements keep the string (it is baked into the template) and so do
custom elements, which compile to `createPlainElement` -- matching the
upstream gate on `ElementTypes.COMPONENT`.
Merged from vuejs/core#15745
In a Vapor template, a static
styleon a component reaches the child as a string, while VDOM compiles it to an object. Code that expects the object breaks:{ ...attrs.style }spreads characters andpatchStylethrows, and atypeof style === 'object'check silently drops the style (playground). Hydration mismatches too, since SSR renders the object.antdv-next's Menu spreads
...attrs.styleand its docs use<a-menu style="width: 256px">, so that demo crashes under a Vapor parent. Their Vapor port does the same in TextArea.This parses a static
styleon components withparseStringStyle, as VDOM'stransformStyledoes. Slot outlets and elements keep the string, as in VDOM.