Skip to content

Commit f0b0988

Browse files
committed
handle bind-name for partials and warn old usage
1 parent 19d006f commit f0b0988

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/deprecations.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ if (process.env.NODE_ENV !== 'production') {
158158
)
159159
},
160160

161+
PARTIAL_NAME: function (id) {
162+
wanr(
163+
'<partial name="' + id + '">: mustache interpolations inside attributes ' +
164+
'will be deprecated in 1.0.0. Use bind-name="expression" instead.'
165+
)
166+
},
167+
161168
REF_IN_CHILD: function () {
162169
warn(
163170
'v-ref or ref can no longer be used on a component root in its own ' +

src/element-directives/partial.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,28 @@ module.exports = {
1010
this.anchor = _.createAnchor('v-partial')
1111
_.replace(el, this.anchor)
1212
var id = el.getAttribute('name')
13-
var tokens = textParser.parse(id)
14-
if (tokens) {
15-
// dynamic partial
16-
this.setupDynamic(tokens)
13+
if (id != null) {
14+
var tokens = textParser.parse(id)
15+
if (tokens) {
16+
// dynamic partial
17+
this.setupDynamic(textParser.tokensToExp(tokens))
18+
if (process.env.NODE_ENV !== 'production') {
19+
_.deprecation.PARTIAL_NAME(id)
20+
}
21+
} else {
22+
// static partial
23+
this.insert(id)
24+
}
1725
} else {
18-
// static partial
19-
this.insert(id)
26+
id = el.getAttribute('bind-name')
27+
if (id) {
28+
this.setupDynamic(id)
29+
}
2030
}
2131
},
2232

23-
setupDynamic: function (tokens) {
33+
setupDynamic: function (exp) {
2434
var self = this
25-
var exp = textParser.tokensToExp(tokens)
2635
this.unwatch = this.vm.$watch(exp, function (value) {
2736
vIf.remove.call(self)
2837
self.insert(value)

0 commit comments

Comments
 (0)