Skip to content

fix(compat): should not warn COMPILER_V_BIND_OBJECT_ORDER when using v-bind together with v-for #12993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/compiler-core/src/transforms/transformElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,9 @@ export function buildProps(
hasDynamicKeys = true
if (exp) {
if (isVBind) {
// #10696 in case a v-bind object contains ref
pushRefVForMarker()
// have to merge early for compat build check
pushMergeArg()
if (__COMPAT__) {
// have to merge early for compat build check
pushMergeArg()
// 2.x v-bind object order compat
if (__DEV__) {
const hasOverridableKeys = mergeArgs.some(arg => {
Expand Down Expand Up @@ -641,6 +639,9 @@ export function buildProps(
}
}

// #10696 in case a v-bind object contains ref
pushRefVForMarker()
pushMergeArg()
mergeArgs.push(exp)
} else {
// v-on="obj" -> toHandlers(obj)
Expand Down
10 changes: 10 additions & 0 deletions packages/vue-compat/__tests__/compiler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ test('COMPILER_V_BIND_OBJECT_ORDER', () => {
).toHaveBeenWarned()
})

test('should not warn COMPILER_V_BIND_OBJECT_ORDER work with vFor', () => {
const vm = new Vue({
template: `<div><div v-bind="{ id: 'bar', class: 'baz' }" v-for="item in 5" /></div>`,
}).$mount()
expect(vm.$el).toBeInstanceOf(HTMLDivElement)
expect(
CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER,
).not.toHaveBeenWarned()
})

test('COMPILER_V_ON_NATIVE', () => {
const spy = vi.fn()
const vm = new Vue({
Expand Down