File tree 4 files changed +20
-2
lines changed
4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export type Config = {
18
18
keyCodes: { [ key : string ] : number | Array < number > } ;
19
19
// platform
20
20
isReservedTag: ( x ? : string ) => boolean ;
21
+ isReservedAttr: ( x ? : string ) => boolean ;
21
22
parsePlatformTagName: ( x : string ) => string ;
22
23
isUnknownElement: ( x ? : string ) => boolean ;
23
24
getTagNamespace: ( x ? : string ) => string | void ;
@@ -71,6 +72,12 @@ export default ({
71
72
*/
72
73
isReservedTag : no ,
73
74
75
+ /**
76
+ * Check if an attribute is reserved so that it cannot be used as a component
77
+ * prop. This is platform-dependent and may be overwritten.
78
+ */
79
+ isReservedAttr : no ,
80
+
74
81
/**
75
82
* Check if a tag is an unknown element.
76
83
* Platform-dependent.
Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
+ import config from '../config'
3
4
import Dep from '../observer/dep'
4
5
import Watcher from '../observer/watcher'
5
6
@@ -53,7 +54,11 @@ export function initState (vm: Component) {
53
54
if ( opts . watch ) initWatch ( vm , opts . watch )
54
55
}
55
56
56
- const isReservedProp = { key : 1 , ref : 1 , slot : 1 }
57
+ const isReservedProp = {
58
+ key : 1 ,
59
+ ref : 1 ,
60
+ slot : 1
61
+ }
57
62
58
63
function initProps ( vm : Component , propsOptions : Object ) {
59
64
const propsData = vm . $options . propsData || { }
@@ -69,7 +74,7 @@ function initProps (vm: Component, propsOptions: Object) {
69
74
const value = validateProp ( key , propsOptions , propsData , vm )
70
75
/* istanbul ignore else */
71
76
if ( process . env . NODE_ENV !== 'production' ) {
72
- if ( isReservedProp [ key ] ) {
77
+ if ( isReservedProp [ key ] || config . isReservedAttr ( key ) ) {
73
78
warn (
74
79
`"${ key } " is a reserved attribute and cannot be used as component prop.` ,
75
80
vm
Original file line number Diff line number Diff line change @@ -13,13 +13,15 @@ import {
13
13
query ,
14
14
mustUseProp ,
15
15
isReservedTag ,
16
+ isReservedAttr ,
16
17
getTagNamespace ,
17
18
isUnknownElement
18
19
} from 'web/util/index'
19
20
20
21
// install platform specific utils
21
22
Vue . config . mustUseProp = mustUseProp
22
23
Vue . config . isReservedTag = isReservedTag
24
+ Vue . config . isReservedAttr = isReservedAttr
23
25
Vue . config . getTagNamespace = getTagNamespace
24
26
Vue . config . isUnknownElement = isUnknownElement
25
27
Original file line number Diff line number Diff line change 2
2
3
3
import { makeMap } from 'shared/util'
4
4
5
+ // these are reserved for web because they are directly compiled away
6
+ // during template compilation
7
+ export const isReservedAttr = makeMap ( 'style,class' )
8
+
5
9
// attributes that should be using props for binding
6
10
const acceptValue = makeMap ( 'input,textarea,option,select' )
7
11
export const mustUseProp = ( tag : string , type : ?string , attr : string ) : boolean => {
You can’t perform that action at this time.
0 commit comments