Skip to content

Commit c315505

Browse files
committed
warn literal directives
1 parent d8c413e commit c315505

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/deprecations.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ if (process.env.NODE_ENV !== 'production') {
213213
'The global "interpolate" config will be deprecated in 1.0.0. Use "v-pre" ' +
214214
'on elements that should be skipped by the template compiler.'
215215
)
216+
},
217+
218+
LITERAL: function () {
219+
warn(
220+
'Literal directives will be deprecated in 1.0.0. Just add quotes if ' +
221+
'you want to pass a literal string to the directive.'
222+
)
216223
}
217224

218225
}

src/directive.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ Directive.prototype._bind = function () {
7171
this.el.removeAttribute('bind-' + name)
7272
} else if (name === 'on') {
7373
this.el.removeAttribute('on-' + this.arg)
74-
} else if (name === 'transition') {
75-
this.el.removeAttribute(name)
74+
} else if (name === 'transition' || name === 'el') {
75+
this.el.removeAttribute(this.arg ? 'bind-' + name : name)
7676
}
7777
}
7878
if (typeof def === 'function') {
@@ -134,6 +134,16 @@ Directive.prototype._bind = function () {
134134
Directive.prototype._checkDynamicLiteral = function () {
135135
var expression = this.expression
136136
if (expression && this.isLiteral) {
137+
138+
if (process.env.NODE_ENV !== 'production') {
139+
if (this.name !== 'el' &&
140+
this.name !== 'ref' &&
141+
this.name !== 'transition' &&
142+
this.name !== 'component') {
143+
_.deprecation.LITERAL()
144+
}
145+
}
146+
137147
var tokens = textParser.parse(expression)
138148
if (tokens) {
139149
var exp = textParser.tokensToExp(tokens)

0 commit comments

Comments
 (0)