Skip to content

Commit

Permalink
refactor(runtime-core): adjust patchProp value arguments order
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yyx990803 committed Mar 9, 2020
1 parent cd34603 commit ca5f39e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/runtime-core/src/hydration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ export function createHydrationFunctions({
) {
for (const key in props) {
if (!isReservedProp(key) && isOn(key)) {
patchProp(el, key, props[key], null)
patchProp(el, key, null, props[key])
}
}
} else if (props.onClick != null) {
// Fast path for click listeners (which is most often) to avoid
// iterating through props.
patchProp(el, 'onClick', props.onClick, null)
patchProp(el, 'onClick', null, props.onClick)
}
// vnode hooks
const { onVnodeBeforeMount, onVnodeMounted } = props
Expand Down
16 changes: 8 additions & 8 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export interface RendererOptions<HostNode = any, HostElement = any> {
patchProp(
el: HostElement,
key: string,
value: any,
oldValue: any,
prevValue: any,
nextValue: any,
isSVG?: boolean,
prevChildren?: VNode<HostNode, HostElement>[],
parentComponent?: ComponentInternalInstance | null,
Expand Down Expand Up @@ -541,7 +541,7 @@ function baseCreateRenderer<
if (props != null) {
for (const key in props) {
if (!isReservedProp(key)) {
hostPatchProp(el, key, props[key], null, isSVG)
hostPatchProp(el, key, null, props[key], isSVG)
}
}
if (props.onVnodeBeforeMount != null) {
Expand Down Expand Up @@ -667,14 +667,14 @@ function baseCreateRenderer<
// this flag is matched when the element has dynamic class bindings.
if (patchFlag & PatchFlags.CLASS) {
if (oldProps.class !== newProps.class) {
hostPatchProp(el, 'class', newProps.class, null, isSVG)
hostPatchProp(el, 'class', null, newProps.class, isSVG)
}
}

// style
// this flag is matched when the element has dynamic style bindings
if (patchFlag & PatchFlags.STYLE) {
hostPatchProp(el, 'style', newProps.style, oldProps.style, isSVG)
hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG)
}

// props
Expand All @@ -694,8 +694,8 @@ function baseCreateRenderer<
hostPatchProp(
el,
key,
next,
prev,
next,
isSVG,
n1.children as HostVNode[],
parentComponent,
Expand Down Expand Up @@ -814,8 +814,8 @@ function baseCreateRenderer<
hostPatchProp(
el,
key,
next,
prev,
next,
isSVG,
vnode.children as HostVNode[],
parentComponent,
Expand All @@ -830,8 +830,8 @@ function baseCreateRenderer<
hostPatchProp(
el,
key,
null,
oldProps[key],
null,
isSVG,
vnode.children as HostVNode[],
parentComponent,
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/patchProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { RendererOptions } from '@vue/runtime-core'
export const patchProp: RendererOptions<Node, Element>['patchProp'] = (
el,
key,
nextValue,
prevValue,
nextValue,
isSVG = false,
prevChildren,
parentComponent,
Expand Down
4 changes: 2 additions & 2 deletions packages/runtime-test/src/patchProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { isOn } from '@vue/shared'
export function patchProp(
el: TestElement,
key: string,
nextValue: any,
prevValue: any
prevValue: any,
nextValue: any
) {
logNodeOp({
type: NodeOpTypes.PATCH,
Expand Down

2 comments on commit ca5f39e

@yyx990803
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @rigor789

@rigor789
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up @yyx990803!

Please sign in to comment.