@@ -9,11 +9,17 @@ export default function createAPIComponent(Vue, Component, events = [], single =
99 before ( fn ) {
1010 beforeFns . push ( fn )
1111 } ,
12- open ( data , renderFn , instanceSingle ) {
13- if ( typeof renderFn !== 'function' ) {
14- instanceSingle = renderFn
12+ open ( data , renderFn , options ) {
13+ if ( typeof renderFn !== 'function' && options === undefined ) {
14+ options = renderFn
1515 renderFn = null
1616 }
17+ let instanceSingle = options
18+ if ( typeof options === 'object' ) {
19+ instanceSingle = ! ! options . single
20+ delete options . single
21+ }
22+
1723 beforeFns . forEach ( ( before ) => {
1824 before ( data , renderFn , instanceSingle )
1925 } )
@@ -26,7 +32,7 @@ export default function createAPIComponent(Vue, Component, events = [], single =
2632 // singleComponent.show && singleComponent.show()
2733 return singleComponent
2834 }
29- const component = instantiateComponent ( Vue , Component , data , renderFn )
35+ const component = instantiateComponent ( Vue , Component , data , renderFn , options )
3036 const instance = component . $parent
3137 const originRemove = component . remove
3238
@@ -61,13 +67,27 @@ export default function createAPIComponent(Vue, Component, events = [], single =
6167 } ,
6268 create ( config , renderFn , single ) {
6369 const ownerInstance = this
70+ const isInVueInstance = ! ! ownerInstance . $on
6471 const renderData = parseRenderData ( config , events )
6572
6673 cancelWatchProps ( )
6774 processProps ( )
6875 processEvents ( )
6976
70- const component = api . open ( renderData , renderFn , single )
77+ if ( typeof renderFn !== 'function' && single === undefined ) {
78+ single = ! ! renderFn
79+ renderFn = null
80+ }
81+ // to get Vue options
82+ // store router i18n ...
83+ const options = {
84+ single : single
85+ }
86+ if ( isInVueInstance ) {
87+ options . parent = ownerInstance
88+ }
89+
90+ const component = api . open ( renderData , renderFn , options )
7191 if ( component . __cube__parent !== ownerInstance ) {
7292 component . __cube__parent = ownerInstance
7393 const beforeDestroy = function ( ) {
@@ -78,7 +98,7 @@ export default function createAPIComponent(Vue, Component, events = [], single =
7898 ownerInstance . $off ( 'hook:beforeDestroy' , beforeDestroy )
7999 component . __cube__parent = null
80100 }
81- ownerInstance . $on && ownerInstance . $on ( 'hook:beforeDestroy' , beforeDestroy )
101+ isInVueInstance && ownerInstance . $on ( 'hook:beforeDestroy' , beforeDestroy )
82102 }
83103 return component
84104
@@ -100,7 +120,7 @@ export default function createAPIComponent(Vue, Component, events = [], single =
100120 renderData . props [ key ] = propKey
101121 }
102122 } )
103- if ( ownerInstance . $watch ) {
123+ if ( isInVueInstance ) {
104124 ownerInstance . __createAPI_watcher = ownerInstance . $watch ( function ( ) {
105125 const props = { }
106126 watchKeys . forEach ( ( key , i ) => {
0 commit comments