61 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-09-19 11:35:38 -04:00
import { patchClass } from './modules/class'
import { patchStyle } from './modules/style'
import { patchAttr } from './modules/attrs'
import { patchDOMProp } from './modules/props'
import { patchEvent } from './modules/events'
2018-10-17 12:20:54 -04:00
import { isOn } from '@vue/shared'
2019-09-10 12:11:08 -04:00
import {
VNode,
ComponentInternalInstance,
SuspenseBoundary
} from '@vue/runtime-core'
export function patchProp(
2018-09-19 11:35:38 -04:00
el: Element,
key: string,
nextValue: any,
2019-05-26 15:38:55 +08:00
prevValue: any,
2018-09-19 11:35:38 -04:00
isSVG: boolean,
prevChildren?: VNode[],
2019-09-06 16:58:32 -04:00
parentComponent?: ComponentInternalInstance,
2019-09-10 12:11:08 -04:00
parentSuspense?: SuspenseBoundary<Node, Element>,
unmountChildren?: any
2018-09-19 11:35:38 -04:00
) {
switch (key) {
// special
case 'class':
patchClass(el, nextValue, isSVG)
break
case 'style':
patchStyle(el, prevValue, nextValue)
2018-09-19 11:35:38 -04:00
break
2019-10-10 18:02:51 -04:00
case 'modelValue':
case 'onUpdate:modelValue':
// Do nothing. This is handled by v-model directives.
break
2018-09-19 11:35:38 -04:00
default:
2018-10-17 12:20:54 -04:00
if (isOn(key)) {
patchEvent(
el,
key.slice(2).toLowerCase(),
prevValue,
nextValue,
parentComponent
)
2019-06-03 09:43:28 +08:00
} else if (!isSVG && key in el) {
patchDOMProp(
el,
key,
nextValue,
prevChildren,
parentComponent,
2019-09-10 12:11:08 -04:00
parentSuspense,
unmountChildren
)
2018-09-19 11:35:38 -04:00
} else {
patchAttr(el, key, nextValue)
2018-09-19 11:35:38 -04:00
}
break
}
}