]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: refactor
authorEvan You <yyx990803@gmail.com>
Sun, 18 Apr 2021 02:50:16 +0000 (22:50 -0400)
committerEvan You <yyx990803@gmail.com>
Sun, 18 Apr 2021 02:50:16 +0000 (22:50 -0400)
packages/compiler-core/src/parse.ts
packages/compiler-core/src/transforms/transformElement.ts
packages/compiler-core/src/transforms/vBind.ts

index 383c115bbaf48c81ffc8b76fdc574b31533e07e8..feee2a812394cf3407c70c24b252e4064376bb85 100644 (file)
@@ -748,20 +748,27 @@ function parseAttribute(
     const modifiers = match[3] ? match[3].substr(1).split('.') : []
 
     // 2.x compat v-bind:foo.sync -> v-model:foo
-    if (
-      __COMPAT__ &&
-      dirName === 'bind' &&
-      arg &&
-      modifiers.includes('sync') &&
-      checkCompatEnabled(
-        CompilerDeprecationTypes.COMPILER_V_BIND_SYNC,
-        context,
-        loc,
-        arg.loc.source
-      )
-    ) {
-      dirName = 'model'
-      modifiers.splice(modifiers.indexOf('sync'), 1)
+    if (__COMPAT__ && dirName === 'bind' && arg) {
+      if (
+        modifiers.includes('sync') &&
+        checkCompatEnabled(
+          CompilerDeprecationTypes.COMPILER_V_BIND_SYNC,
+          context,
+          loc,
+          arg.loc.source
+        )
+      ) {
+        dirName = 'model'
+        modifiers.splice(modifiers.indexOf('sync'), 1)
+      }
+
+      if (__DEV__ && modifiers.includes('prop')) {
+        checkCompatEnabled(
+          CompilerDeprecationTypes.COMPILER_V_BIND_PROP,
+          context,
+          loc
+        )
+      }
     }
 
     return {
index ce85c958d67876167c805d64457c85b2db0ca5cf..d0ceaa3939b84ca43e015ee73d032e008a9eac17 100644 (file)
@@ -92,6 +92,7 @@ export const transformElement: NodeTransform = (node, context) => {
       ? resolveComponentType(node as ComponentNode, context)
       : `"${tag}"`
 
+    // 2.x <template> with no directives compat
     if (
       __COMPAT__ &&
       tag === 'template' &&
@@ -261,9 +262,7 @@ export function resolveComponentType(
       // if not <component>, only is value that starts with "vue:" will be
       // treated as component by the parse phase and reach here, unless it's
       // compat mode where all is values are considered components
-      tag = __COMPAT__
-        ? isProp.value!.content.replace(/^vue:/, '')
-        : isProp.value!.content.slice(4)
+      tag = isProp.value!.content.replace(/^vue:/, '')
     } else {
       const exp =
         isProp.type === NodeTypes.ATTRIBUTE
@@ -509,6 +508,7 @@ export function buildProps(
           }
           if (isVBind) {
             if (__COMPAT__) {
+              // 2.x v-bind object order compat
               if (__DEV__) {
                 const hasOverridableKeys = mergeArgs.some(arg => {
                   if (arg.type === NodeTypes.JS_OBJECT_EXPRESSION) {
index acfe695ea2e77d2485ffd4142806fb08325d9195..c1faed1a08728cba3fcc1e4e165ebeed9ae88a0e 100644 (file)
@@ -3,10 +3,6 @@ import { createObjectProperty, createSimpleExpression, NodeTypes } from '../ast'
 import { createCompilerError, ErrorCodes } from '../errors'
 import { camelize } from '@vue/shared'
 import { CAMELIZE } from '../runtimeHelpers'
-import {
-  checkCompatEnabled,
-  CompilerDeprecationTypes
-} from '../compat/compatConfig'
 
 // v-bind without arg is handled directly in ./transformElements.ts due to it affecting
 // codegen for the entire props object. This transform here is only for v-bind
@@ -37,18 +33,6 @@ export const transformBind: DirectiveTransform = (dir, _node, context) => {
     }
   }
 
-  if (__COMPAT__) {
-    if (modifiers.includes('prop')) {
-      checkCompatEnabled(
-        CompilerDeprecationTypes.COMPILER_V_BIND_PROP,
-        context,
-        loc
-      )
-    }
-    // .sync handling is performed directly in the parse phase to transform
-    // it into v-model:arg equivalent.
-  }
-
   if (
     !exp ||
     (exp.type === NodeTypes.SIMPLE_EXPRESSION && !exp.content.trim())