2018-09-19 15:35:38 +00: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 16:20:54 +00:00
|
|
|
import { isOn } from '@vue/shared'
|
2019-05-26 07:19:44 +00:00
|
|
|
import { VNode } from '@vue/runtime-core'
|
2018-10-12 21:42:08 +00:00
|
|
|
|
2019-05-26 07:19:44 +00:00
|
|
|
export function patchProp(
|
2018-09-19 15:35:38 +00:00
|
|
|
el: Element,
|
|
|
|
key: string,
|
|
|
|
nextValue: any,
|
2019-05-26 07:38:55 +00:00
|
|
|
prevValue: any,
|
2018-09-19 15:35:38 +00:00
|
|
|
isSVG: boolean,
|
2019-05-26 07:19:44 +00:00
|
|
|
prevChildren?: VNode[],
|
|
|
|
unmountChildren?: any
|
2018-09-19 15:35:38 +00:00
|
|
|
) {
|
|
|
|
switch (key) {
|
|
|
|
// special
|
|
|
|
case 'class':
|
|
|
|
patchClass(el, nextValue, isSVG)
|
|
|
|
break
|
|
|
|
case 'style':
|
2019-05-26 07:19:44 +00:00
|
|
|
patchStyle(el, prevValue, nextValue)
|
2018-09-19 15:35:38 +00:00
|
|
|
break
|
|
|
|
default:
|
2018-10-17 16:20:54 +00:00
|
|
|
if (isOn(key)) {
|
|
|
|
patchEvent(el, key.slice(2).toLowerCase(), prevValue, nextValue)
|
2019-06-03 01:43:28 +00:00
|
|
|
} else if (!isSVG && key in el) {
|
2019-05-26 07:19:44 +00:00
|
|
|
patchDOMProp(el, key, nextValue, prevChildren, unmountChildren)
|
2018-09-19 15:35:38 +00:00
|
|
|
} else {
|
|
|
|
patchAttr(el, key, nextValue, isSVG)
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|