File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 33import { compileToFunctions } from 'vue-template-compiler'
44
55export function compileTemplate ( component : Component ) {
6- Object . assign ( component , compileToFunctions ( component . template ) )
6+ if ( component . extends ) {
7+ compileTemplate ( component . extends )
8+ }
9+ if ( component . template ) {
10+ Object . assign ( component , compileToFunctions ( component . template ) )
11+ }
712}
Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ export default function createConstructor (
4343 stubComponents ( component , mountingOptions . stubs )
4444 }
4545
46- if ( ! component . render && component . template && ! component . functional ) {
46+ if ( ! component . render &&
47+ ( component . template || component . extends ) &&
48+ ! component . functional ) {
4749 compileTemplate ( component )
4850 }
4951
Original file line number Diff line number Diff line change @@ -56,6 +56,37 @@ describe('mount', () => {
5656 }
5757 } )
5858
59+ it ( 'handles uncompiled extended Vue component' , ( ) => {
60+ const BaseComponent = {
61+ template : '<div />'
62+ }
63+ const TestComponent = {
64+ extends : BaseComponent
65+ }
66+ const wrapper = mount ( TestComponent )
67+ expect ( wrapper . findAll ( 'div' ) . length ) . to . equal ( 1 )
68+ } )
69+
70+ it ( 'handles nested uncompiled extended Vue component' , ( ) => {
71+ const BaseComponent = {
72+ template : '<div />'
73+ }
74+ const TestComponentA = {
75+ extends : BaseComponent
76+ }
77+ const TestComponentB = {
78+ extends : TestComponentA
79+ }
80+ const TestComponentC = {
81+ extends : TestComponentB
82+ }
83+ const TestComponentD = {
84+ extends : TestComponentC
85+ }
86+ const wrapper = mount ( TestComponentD )
87+ expect ( wrapper . findAll ( 'div' ) . length ) . to . equal ( 1 )
88+ } )
89+
5990 it ( 'does not use cached component' , ( ) => {
6091 ComponentWithMixin . methods . someMethod = sinon . stub ( )
6192 mount ( ComponentWithMixin )
You can’t perform that action at this time.
0 commit comments