Skip to content

Commit 12ad53c

Browse files
committed
prefix deprecation warning
1 parent 184ff7d commit 12ad53c

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

src/config.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
module.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

src/deprecations.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

test/unit/specs/misc_spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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
})

0 commit comments

Comments
 (0)