})
})
+ test('staticClass + class', () => {
+ expect(
+ h('div', {
+ class: { foo: true },
+ staticClass: 'bar'
+ })
+ ).toMatchObject({
+ props: {
+ class: 'bar foo'
+ }
+ })
+ })
+
+ test('staticStyle + style', () => {
+ expect(
+ h('div', {
+ style: { color: 'red' },
+ staticStyle: { fontSize: '14px' }
+ })
+ ).toMatchObject({
+ props: {
+ style: {
+ color: 'red',
+ fontSize: '14px'
+ }
+ }
+ })
+ })
+
test('on / nativeOn', () => {
const fn = () => {}
expect(
extend,
isArray,
isObject,
+ normalizeClass,
+ normalizeStyle,
ShapeFlags,
toHandlerKey
} from '@vue/shared'
}
}
-function convertLegacyProps(legacyProps?: LegacyVNodeProps): Data & VNodeProps {
+function convertLegacyProps(
+ legacyProps?: LegacyVNodeProps
+): Data & VNodeProps | null {
+ if (!legacyProps) {
+ return null
+ }
+
const converted: Data & VNodeProps = {}
for (const key in legacyProps) {
: incoming
}
}
- } else {
+ } else if (
+ key !== 'refInFor' &&
+ key !== 'staticStyle' &&
+ key !== 'staticClass'
+ ) {
converted[key] = legacyProps[key as keyof LegacyVNodeProps]
}
}
+ if (legacyProps.staticClass) {
+ converted.class = normalizeClass([legacyProps.staticClass, converted.class])
+ }
+ if (legacyProps.staticStyle) {
+ converted.style = normalizeStyle([legacyProps.staticStyle, converted.style])
+ }
+
return converted
}