@@ -55,6 +55,11 @@ import {
55
55
import { buildSlots } from './vSlot'
56
56
import { getConstantType } from './hoistStatic'
57
57
import { BindingTypes } from '../options'
58
+ import {
59
+ checkCompatEnabled ,
60
+ CompilerDeprecationTypes ,
61
+ isCompatEnabled
62
+ } from '../compat/compatConfig'
58
63
59
64
// some directive transforms (e.g. v-model) may return a symbol for runtime
60
65
// import, which should be used instead of a resolveDirective call.
@@ -450,8 +455,8 @@ export function buildProps(
450
455
} else {
451
456
// directives
452
457
const { name, arg, exp, loc } = prop
453
- const isBind = name === 'bind'
454
- const isOn = name === 'on'
458
+ const isVBind = name === 'bind'
459
+ const isVOn = name === 'on'
455
460
456
461
// skip v-slot - it is handled by its dedicated transform.
457
462
if ( name === 'slot' ) {
@@ -469,17 +474,17 @@ export function buildProps(
469
474
// skip v-is and :is on <component>
470
475
if (
471
476
name === 'is' ||
472
- ( isBind && isComponentTag ( tag ) && isBindKey ( arg , 'is' ) )
477
+ ( isVBind && isComponentTag ( tag ) && isBindKey ( arg , 'is' ) )
473
478
) {
474
479
continue
475
480
}
476
481
// skip v-on in SSR compilation
477
- if ( isOn && ssr ) {
482
+ if ( isVOn && ssr ) {
478
483
continue
479
484
}
480
485
481
486
// special case for v-bind and v-on with no argument
482
- if ( ! arg && ( isBind || isOn ) ) {
487
+ if ( ! arg && ( isVBind || isVOn ) ) {
483
488
hasDynamicKeys = true
484
489
if ( exp ) {
485
490
if ( properties . length ) {
@@ -488,7 +493,49 @@ export function buildProps(
488
493
)
489
494
properties = [ ]
490
495
}
491
- if ( isBind ) {
496
+ if ( isVBind ) {
497
+ if ( __COMPAT__ ) {
498
+ if ( __DEV__ ) {
499
+ const hasOverridableKeys = mergeArgs . some ( arg => {
500
+ if ( arg . type === NodeTypes . JS_OBJECT_EXPRESSION ) {
501
+ return arg . properties . some ( ( { key } ) => {
502
+ if (
503
+ key . type !== NodeTypes . SIMPLE_EXPRESSION ||
504
+ ! key . isStatic
505
+ ) {
506
+ return true
507
+ }
508
+ return (
509
+ key . content !== 'class' &&
510
+ key . content !== 'style' &&
511
+ ! isOn ( key . content )
512
+ )
513
+ } )
514
+ } else {
515
+ // dynamic expression
516
+ return true
517
+ }
518
+ } )
519
+ if ( hasOverridableKeys ) {
520
+ checkCompatEnabled (
521
+ CompilerDeprecationTypes . COMPILER_V_BIND_OBJECT_ORDER ,
522
+ context ,
523
+ loc
524
+ )
525
+ }
526
+ }
527
+
528
+ if (
529
+ isCompatEnabled (
530
+ CompilerDeprecationTypes . COMPILER_V_BIND_OBJECT_ORDER ,
531
+ context
532
+ )
533
+ ) {
534
+ mergeArgs . unshift ( exp )
535
+ continue
536
+ }
537
+ }
538
+
492
539
mergeArgs . push ( exp )
493
540
} else {
494
541
// v-on="obj" -> toHandlers(obj)
@@ -502,7 +549,7 @@ export function buildProps(
502
549
} else {
503
550
context . onError (
504
551
createCompilerError (
505
- isBind
552
+ isVBind
506
553
? ErrorCodes . X_V_BIND_NO_EXPRESSION
507
554
: ErrorCodes . X_V_ON_NO_EXPRESSION ,
508
555
loc
0 commit comments