File tree Expand file tree Collapse file tree 3 files changed +39
-8
lines changed Expand file tree Collapse file tree 3 files changed +39
-8
lines changed Original file line number Diff line number Diff line change 1
1
module . exports = {
2
2
3
- /**
4
- * The prefix to look for when parsing directives.
5
- *
6
- * @type {String }
7
- */
8
-
9
- prefix : 'v-' ,
10
-
11
3
/**
12
4
* Whether to print debug messages.
13
5
* Also enables stack trace for warnings.
@@ -104,6 +96,25 @@ module.exports = {
104
96
105
97
}
106
98
99
+ /**
100
+ * The prefix to look for when parsing directives.
101
+ *
102
+ * @type {String }
103
+ */
104
+
105
+ var prefix = 'v-'
106
+ Object . defineProperty ( module . exports , 'prefix' , {
107
+ get : function ( ) {
108
+ return prefix
109
+ } ,
110
+ set : function ( val ) {
111
+ prefix = val
112
+ if ( process . env . NODE_ENV !== 'production' ) {
113
+ require ( './util' ) . deprecation . PREFIX ( )
114
+ }
115
+ }
116
+ } )
117
+
107
118
/**
108
119
* Interpolation delimiters.
109
120
* We need to mark the changed flag so that the text parser
Original file line number Diff line number Diff line change @@ -220,6 +220,13 @@ if (process.env.NODE_ENV !== 'production') {
220
220
'It is no longer necessary to declare literal directives in 1.0.0. Just ' +
221
221
'use the dot-equal syntax (v-dir.="string") to indicate a literal value.'
222
222
)
223
+ } ,
224
+
225
+ PREFIX : function ( ) {
226
+ warn (
227
+ 'The "prefix" global config will be deprecated in 1.0.0. All directives ' +
228
+ 'will consistently use the v- or v. prefixes.'
229
+ )
223
230
}
224
231
225
232
}
Original file line number Diff line number Diff line change @@ -358,4 +358,17 @@ describe('Misc', function () {
358
358
} )
359
359
expect ( hasWarned ( __ , 'Unknown custom element' ) ) . toBe ( true )
360
360
} )
361
+
362
+ it ( 'changing prefix' , function ( ) {
363
+ Vue . config . prefix = 'lol-'
364
+ var vm = new Vue ( {
365
+ el : document . createElement ( 'div' ) ,
366
+ template : '<div lol-text="text"></div>' ,
367
+ data : {
368
+ text : 'hi'
369
+ }
370
+ } )
371
+ expect ( vm . $el . textContent ) . toBe ( 'hi' )
372
+ Vue . config . prefix = 'v-'
373
+ } )
361
374
} )
You can’t perform that action at this time.
0 commit comments