mirror of https://github.com/vuejs/core.git
Merge 8ce63aa707
into ba391f5fdf
This commit is contained in:
commit
9569f9637e
|
@ -2284,6 +2284,31 @@ describe('SSR hydration', () => {
|
||||||
app.mount(container)
|
app.mount(container)
|
||||||
expect(`Hydration style mismatch`).not.toHaveBeenWarned()
|
expect(`Hydration style mismatch`).not.toHaveBeenWarned()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('style var with falsy values', () => {
|
||||||
|
const container = document.createElement('div')
|
||||||
|
container.innerHTML = `<div style="padding: 4px;--bar:;"></div>`
|
||||||
|
const app = createSSRApp({
|
||||||
|
setup() {
|
||||||
|
const value1 = ref<any>(null)
|
||||||
|
const value2 = ref('')
|
||||||
|
const value3 = ref<any>(undefined)
|
||||||
|
useCssVars(() => ({
|
||||||
|
foo: value1.value,
|
||||||
|
bar: value2.value,
|
||||||
|
baz: value3.value,
|
||||||
|
}))
|
||||||
|
return () => h(Child)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const Child = {
|
||||||
|
setup() {
|
||||||
|
return () => h('div', { style: 'padding: 4px' })
|
||||||
|
},
|
||||||
|
}
|
||||||
|
app.mount(container)
|
||||||
|
expect(`Hydration style mismatch`).not.toHaveBeenWarned()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('data-allow-mismatch', () => {
|
describe('data-allow-mismatch', () => {
|
||||||
|
|
|
@ -911,7 +911,7 @@ function toStyleMap(str: string): Map<string, string> {
|
||||||
let [key, value] = item.split(':')
|
let [key, value] = item.split(':')
|
||||||
key = key.trim()
|
key = key.trim()
|
||||||
value = value && value.trim()
|
value = value && value.trim()
|
||||||
if (key && value) {
|
if (key) {
|
||||||
styleMap.set(key, value)
|
styleMap.set(key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -945,10 +945,13 @@ function resolveCssVars(
|
||||||
) {
|
) {
|
||||||
const cssVars = instance.getCssVars()
|
const cssVars = instance.getCssVars()
|
||||||
for (const key in cssVars) {
|
for (const key in cssVars) {
|
||||||
expectedMap.set(
|
const value = cssVars[key]
|
||||||
`--${getEscapedCssVarName(key, false)}`,
|
if (isRenderableAttrValue(value)) {
|
||||||
String(cssVars[key]),
|
expectedMap.set(
|
||||||
)
|
`--${getEscapedCssVarName(key, false)}`,
|
||||||
|
String(value).trim(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vnode === root && instance.parent) {
|
if (vnode === root && instance.parent) {
|
||||||
|
|
Loading…
Reference in New Issue