diff --git a/src/compiler/codegen/index.js b/src/compiler/codegen/index.js index 4afc4711c2f..9eb705abfcb 100644 --- a/src/compiler/codegen/index.js +++ b/src/compiler/codegen/index.js @@ -52,6 +52,10 @@ export function generate ( } export function genElement (el: ASTElement, state: CodegenState): string { + if (el.parent) { + el.pre = el.pre || el.parent.pre + } + if (el.staticRoot && !el.staticProcessed) { return genStatic(el, state) } else if (el.once && !el.onceProcessed) { @@ -70,7 +74,10 @@ export function genElement (el: ASTElement, state: CodegenState): string { if (el.component) { code = genComponent(el.component, el, state) } else { - const data = el.plain ? undefined : genData(el, state) + let data + if (!el.plain || el.pre) { + data = genData(el, state) + } const children = el.inlineTemplate ? null : genChildren(el, state, true) code = `_c('${el.tag}'${ diff --git a/src/core/vdom/create-element.js b/src/core/vdom/create-element.js index c5cde2c6424..46027084b51 100644 --- a/src/core/vdom/create-element.js +++ b/src/core/vdom/create-element.js @@ -102,7 +102,7 @@ export function _createElement ( config.parsePlatformTagName(tag), data, children, undefined, undefined, context ) - } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) { + } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) { // component vnode = createComponent(Ctor, data, context, children, tag) } else { diff --git a/test/unit/features/directives/pre.spec.js b/test/unit/features/directives/pre.spec.js index 92d3bc85537..ed48bf0f860 100644 --- a/test/unit/features/directives/pre.spec.js +++ b/test/unit/features/directives/pre.spec.js @@ -7,7 +7,7 @@ describe('Directive v-pre', function () {