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