Skip to content

Commit 6755fd9

Browse files
committed
still allow v-component on table elements
1 parent 823e5c0 commit 6755fd9

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/util/debug.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ function enableDebug () {
5050
if (type === 'directive') {
5151
if (id === 'component') {
5252
exports.warn(
53-
'v-component has been deprecated in 0.12. ' +
54-
'Use custom element syntax instead.'
53+
'v-component can only be used on table elements ' +
54+
'in ^0.12.0. Use custom element syntax instead.'
5555
)
5656
return
5757
}
5858
if (id === 'with') {
5959
exports.warn(
60-
'v-with has been deprecated in 0.12. ' +
60+
'v-with has been deprecated in ^0.12.0. ' +
6161
'Use props instead.'
6262
)
6363
return

src/util/misc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var _ = require('./index')
22
var config = require('../config')
3-
var commonTagRE = /^(div|p|span|img|a|br|ul|ol|li|h1|h2|h3|h4|h5|table|tbody|tr|td|pre)$/
3+
var commonTagRE = /^(div|p|span|img|a|br|ul|ol|li|h1|h2|h3|h4|h5|code|pre)$/
4+
var tableElementsRE = /^caption|colgroup|thead|tfoot|tbody|tr|td|th$/
45

56
/**
67
* Check if an element is a component, if yes return its
@@ -23,6 +24,11 @@ exports.checkComponent = function (el, options) {
2324
_.resolveAsset(options, 'components', tag)
2425
) {
2526
return tag
27+
} else if (
28+
tableElementsRE.test(tag) &&
29+
(tag = _.attr(el, 'component'))
30+
) {
31+
return tag
2632
}
2733
}
2834

test/unit/specs/directives/component_spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ if (_.inBrowser) {
4848
expect(el.innerHTML).toBe('<p>123</p>')
4949
})
5050

51+
it('allow v-component on table elements', function () {
52+
var vm = new Vue({
53+
el: el,
54+
template: '<table><tbody><tr v-component="test"></tr></tbody></table>',
55+
components: {
56+
test: {
57+
data: function () {
58+
return { a: 123 }
59+
},
60+
template: '<td>{{a}}</td>'
61+
}
62+
}
63+
})
64+
expect(el.innerHTML).toBe(vm.$options.template.replace(/<tr.*\/tr>/, '<tr><td>123</td></tr>'))
65+
expect(_.warn).not.toHaveBeenCalled()
66+
})
67+
5168
it('inline-template', function () {
5269
var vm = new Vue({
5370
el: el,

0 commit comments

Comments
 (0)