Skip to content

Commit fc9b33b

Browse files
committed
relax v-component limitation
1 parent 428bc4f commit fc9b33b

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/compiler/compile.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function compileElement (el, options) {
245245
}
246246
// check component
247247
if (!linkFn) {
248-
linkFn = checkComponent(el, options)
248+
linkFn = checkComponent(el, options, hasAttrs)
249249
}
250250
// normal directives
251251
if (!linkFn && hasAttrs) {
@@ -573,11 +573,12 @@ function checkElementDirectives (el, options) {
573573
*
574574
* @param {Element} el
575575
* @param {Object} options
576+
* @param {Boolean} hasAttrs
576577
* @return {Function|undefined}
577578
*/
578579

579-
function checkComponent (el, options) {
580-
var componentId = _.checkComponent(el, options)
580+
function checkComponent (el, options, hasAttrs) {
581+
var componentId = _.checkComponent(el, options, hasAttrs)
581582
if (componentId) {
582583
var componentLinkFn = function (vm, el, host) {
583584
vm._bindDir('component', el, {

src/util/debug.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ function enableDebug () {
4848
exports.assertAsset = function (val, type, id) {
4949
/* istanbul ignore if */
5050
if (type === 'directive') {
51-
if (id === 'component') {
52-
exports.warn(
53-
'v-component can only be used on table elements ' +
54-
'in ^0.12.0. Use custom element syntax instead.'
55-
)
56-
return
57-
}
5851
if (id === 'with') {
5952
exports.warn(
6053
'v-with has been deprecated in ^0.12.0. ' +
@@ -74,4 +67,4 @@ function enableDebug () {
7467
exports.warn('Failed to resolve ' + type + ': ' + id)
7568
}
7669
}
77-
}
70+
}

src/util/misc.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,12 @@ function formatValue (val) {
7777
*
7878
* @param {Element} el
7979
* @param {Object} options
80+
* @param {Boolean} hasAttrs
8081
* @return {String|undefined}
8182
*/
8283

8384
exports.commonTagRE = /^(div|p|span|img|a|br|ul|ol|li|h1|h2|h3|h4|h5|code|pre)$/
84-
exports.tableElementsRE = /^caption|colgroup|thead|tfoot|tbody|tr|td|th$/
85-
86-
exports.checkComponent = function (el, options) {
85+
exports.checkComponent = function (el, options, hasAttrs) {
8786
var tag = el.tagName.toLowerCase()
8887
if (tag === 'component') {
8988
// dynamic syntax
@@ -96,7 +95,7 @@ exports.checkComponent = function (el, options) {
9695
) {
9796
return tag
9897
} else if (
99-
exports.tableElementsRE.test(tag) &&
98+
hasAttrs &&
10099
(tag = _.attr(el, 'component'))
101100
) {
102101
return tag

0 commit comments

Comments
 (0)