Skip to content

Commit

Permalink
relax v-component limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 25, 2015
1 parent 428bc4f commit fc9b33b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/compiler/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function compileElement (el, options) {
}
// check component
if (!linkFn) {
linkFn = checkComponent(el, options)
linkFn = checkComponent(el, options, hasAttrs)
}
// normal directives
if (!linkFn && hasAttrs) {
Expand Down Expand Up @@ -573,11 +573,12 @@ function checkElementDirectives (el, options) {
*
* @param {Element} el
* @param {Object} options
* @param {Boolean} hasAttrs
* @return {Function|undefined}
*/

function checkComponent (el, options) {
var componentId = _.checkComponent(el, options)
function checkComponent (el, options, hasAttrs) {
var componentId = _.checkComponent(el, options, hasAttrs)
if (componentId) {
var componentLinkFn = function (vm, el, host) {
vm._bindDir('component', el, {
Expand Down
9 changes: 1 addition & 8 deletions src/util/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ function enableDebug () {
exports.assertAsset = function (val, type, id) {
/* istanbul ignore if */
if (type === 'directive') {
if (id === 'component') {
exports.warn(
'v-component can only be used on table elements ' +
'in ^0.12.0. Use custom element syntax instead.'
)
return
}
if (id === 'with') {
exports.warn(
'v-with has been deprecated in ^0.12.0. ' +
Expand All @@ -74,4 +67,4 @@ function enableDebug () {
exports.warn('Failed to resolve ' + type + ': ' + id)
}
}
}
}
7 changes: 3 additions & 4 deletions src/util/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,12 @@ function formatValue (val) {
*
* @param {Element} el
* @param {Object} options
* @param {Boolean} hasAttrs
* @return {String|undefined}
*/

exports.commonTagRE = /^(div|p|span|img|a|br|ul|ol|li|h1|h2|h3|h4|h5|code|pre)$/
exports.tableElementsRE = /^caption|colgroup|thead|tfoot|tbody|tr|td|th$/

exports.checkComponent = function (el, options) {
exports.checkComponent = function (el, options, hasAttrs) {
var tag = el.tagName.toLowerCase()
if (tag === 'component') {
// dynamic syntax
Expand All @@ -96,7 +95,7 @@ exports.checkComponent = function (el, options) {
) {
return tag
} else if (
exports.tableElementsRE.test(tag) &&
hasAttrs &&
(tag = _.attr(el, 'component'))
) {
return tag
Expand Down

0 comments on commit fc9b33b

Please sign in to comment.