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 11module . exports = {
22
3- /**
4- * The prefix to look for when parsing directives.
5- *
6- * @type {String }
7- */
8-
9- prefix : 'v-' ,
10-
113 /**
124 * Whether to print debug messages.
135 * Also enables stack trace for warnings.
@@ -104,6 +96,25 @@ module.exports = {
10496
10597}
10698
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+
107118/**
108119 * Interpolation delimiters.
109120 * 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') {
220220 'It is no longer necessary to declare literal directives in 1.0.0. Just ' +
221221 'use the dot-equal syntax (v-dir.="string") to indicate a literal value.'
222222 )
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+ )
223230 }
224231
225232 }
Original file line number Diff line number Diff line change @@ -358,4 +358,17 @@ describe('Misc', function () {
358358 } )
359359 expect ( hasWarned ( __ , 'Unknown custom element' ) ) . toBe ( true )
360360 } )
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+ } )
361374} )
You can’t perform that action at this time.
0 commit comments