File tree Expand file tree Collapse file tree 3 files changed +36
-12
lines changed
packages/compiler-core/src Expand file tree Collapse file tree 3 files changed +36
-12
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ type DeprecationData = {
31
31
32
32
const deprecationData : Record < CompilerDeprecationTypes , DeprecationData > = {
33
33
[ CompilerDeprecationTypes . IS_ON_ELEMENT ] : {
34
- message : `` ,
34
+ message :
35
+ `Platform-native elements with "is" prop will no longer be ` +
36
+ `treated as components in Vue 3 unless the "is" value is explicitly ` +
37
+ `prefixed with "vue:".` ,
35
38
link : `https://v3.vuejs.org/guide/migration/custom-elements-interop.html`
36
39
} ,
37
40
Original file line number Diff line number Diff line change @@ -30,7 +30,11 @@ import {
30
30
createRoot ,
31
31
ConstantTypes
32
32
} from './ast'
33
- import { CompilerCompatOptions } from './compat/compatConfig'
33
+ import {
34
+ checkCompatEnabled ,
35
+ CompilerCompatOptions ,
36
+ CompilerDeprecationTypes
37
+ } from './compat/compatConfig'
34
38
35
39
type OptionalOptions =
36
40
| 'isNativeTag'
@@ -499,14 +503,28 @@ function parseTag(
499
503
let tagType = ElementTypes . ELEMENT
500
504
const options = context . options
501
505
if ( ! context . inVPre && ! options . isCustomElement ( tag ) ) {
502
- const hasVIs = props . some (
503
- p =>
504
- p . name === 'is' &&
505
- // v-is="xxx" (TODO: deprecate)
506
- ( p . type === NodeTypes . DIRECTIVE ||
507
- // is="vue:xxx"
508
- ( p . value && p . value . content . startsWith ( 'vue:' ) ) )
509
- )
506
+ const hasVIs = props . some ( p => {
507
+ if ( p . name !== 'is' ) return
508
+ // v-is="xxx" (TODO: deprecate)
509
+ if ( p . type === NodeTypes . DIRECTIVE ) {
510
+ return true
511
+ }
512
+ // is="vue:xxx"
513
+ if ( p . value && p . value . content . startsWith ( 'vue:' ) ) {
514
+ return true
515
+ }
516
+ // in compat mode, any is usage is considered a component
517
+ if (
518
+ __COMPAT__ &&
519
+ checkCompatEnabled (
520
+ CompilerDeprecationTypes . IS_ON_ELEMENT ,
521
+ context ,
522
+ p . loc
523
+ )
524
+ ) {
525
+ return true
526
+ }
527
+ } )
510
528
if ( options . isNativeTag && ! hasVIs ) {
511
529
if ( ! options . isNativeTag ( tag ) ) tagType = ElementTypes . COMPONENT
512
530
} else if (
Original file line number Diff line number Diff line change @@ -240,8 +240,11 @@ export function resolveComponentType(
240
240
if ( ! isExplicitDynamic && isProp . type === NodeTypes . ATTRIBUTE ) {
241
241
// <button is="vue:xxx">
242
242
// if not <component>, only is value that starts with "vue:" will be
243
- // treated as component by the parse phase and reach here.
244
- tag = isProp . value ! . content . slice ( 4 )
243
+ // treated as component by the parse phase and reach here, unless it's
244
+ // compat mode where all is values are considered components
245
+ tag = __COMPAT__
246
+ ? isProp . value ! . content . replace ( / ^ v u e : / , '' )
247
+ : isProp . value ! . content . slice ( 4 )
245
248
} else {
246
249
const exp =
247
250
isProp . type === NodeTypes . ATTRIBUTE
You can’t perform that action at this time.
0 commit comments