File tree 3 files changed +40
-2
lines changed
3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change 3
3
import { compileToFunctions } from 'vue-template-compiler'
4
4
5
5
export 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
+ }
7
12
}
Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ export default function createConstructor (
43
43
stubComponents ( component , mountingOptions . stubs )
44
44
}
45
45
46
- if ( ! component . render && component . template && ! component . functional ) {
46
+ if ( ! component . render &&
47
+ ( component . template || component . extends ) &&
48
+ ! component . functional ) {
47
49
compileTemplate ( component )
48
50
}
49
51
Original file line number Diff line number Diff line change @@ -56,6 +56,37 @@ describe('mount', () => {
56
56
}
57
57
} )
58
58
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
+
59
90
it ( 'does not use cached component' , ( ) => {
60
91
ComponentWithMixin . methods . someMethod = sinon . stub ( )
61
92
mount ( ComponentWithMixin )
You can’t perform that action at this time.
0 commit comments