patchProp.ts 515 B

12345678910111213141516171819202122
  1. import { TestElement, logNodeOp, NodeOpTypes } from './nodeOps'
  2. import { isOn } from '@vue/shared'
  3. export function patchProp(
  4. el: TestElement,
  5. key: string,
  6. prevValue: any,
  7. nextValue: any
  8. ) {
  9. logNodeOp({
  10. type: NodeOpTypes.PATCH,
  11. targetNode: el,
  12. propKey: key,
  13. propPrevValue: prevValue,
  14. propNextValue: nextValue
  15. })
  16. el.props[key] = nextValue
  17. if (isOn(key)) {
  18. const event = key.slice(2).toLowerCase()
  19. ;(el.eventListeners || (el.eventListeners = {}))[event] = nextValue
  20. }
  21. }