vue3-yuanma/packages/runtime-test/src/patchProp.ts
Evan You ca5f39ee35 refactor(runtime-core): adjust patchProp value arguments order
BREAKING CHANGE: `RendererOptions.patchProp` arguments order has changed

  The `prevValue` and `nextValue` position has been swapped to keep it
  consistent with other functions in the renderer implementation. This
  only affects custom renderers using the `createRenderer` API.
2020-03-09 16:15:49 -04:00

23 lines
515 B
TypeScript

import { TestElement, logNodeOp, NodeOpTypes } from './nodeOps'
import { isOn } from '@vue/shared'
export function patchProp(
el: TestElement,
key: string,
prevValue: any,
nextValue: any
) {
logNodeOp({
type: NodeOpTypes.PATCH,
targetNode: el,
propKey: key,
propPrevValue: prevValue,
propNextValue: nextValue
})
el.props[key] = nextValue
if (isOn(key)) {
const event = key.slice(2).toLowerCase()
;(el.eventListeners || (el.eventListeners = {}))[event] = nextValue
}
}