@@ -113,36 +113,36 @@ export function mount(
113113 el . setAttribute ( 'id' , rootId )
114114 document . getElementsByTagName ( 'body' ) [ 0 ] . prepend ( el )
115115 }
116- injectStylesBeforeElement ( styleOptions , document , el )
116+ return injectStylesBeforeElement ( styleOptions , document , el ) . then ( ( ) => {
117+ // by default we mount the component into the created element
118+ let target = el
117119
118- // by default we mount the component into the created element
119- let target = el
120-
121- if ( styleOptions && styleOptions . html ) {
122- el . innerHTML = styleOptions . html
123- target = document . getElementById ( 'here' )
124- if ( ! target ) {
125- console . error ( 'mount has HTML with DIV with ID "here"' )
126- console . error ( styleOptions . html )
127- throw new Error (
128- 'Could not find element with ID "here" in the HTML passed' ,
129- )
120+ if ( styleOptions && styleOptions . html ) {
121+ el . innerHTML = styleOptions . html
122+ target = document . getElementById ( 'here' )
123+ if ( ! target ) {
124+ console . error ( 'mount has HTML with DIV with ID "here"' )
125+ console . error ( styleOptions . html )
126+ throw new Error (
127+ 'Could not find element with ID "here" in the HTML passed' ,
128+ )
129+ }
130130 }
131- }
132-
133- const allOptions = Object . assign ( { } , options , {
134- target,
135- } )
136131
137- const component = new Component ( allOptions )
138- if ( options . callbacks ) {
139- // write message callbacks
140- Object . keys ( options . callbacks ) . forEach ( ( message ) => {
141- component . $$ . callbacks [ message ] = [ options . callbacks ! [ message ] ]
132+ const allOptions = Object . assign ( { } , options , {
133+ target,
142134 } )
143- }
144135
145- return cy . wrap ( component )
136+ const component = new Component ( allOptions )
137+ if ( options . callbacks ) {
138+ // write message callbacks
139+ Object . keys ( options . callbacks ) . forEach ( ( message ) => {
140+ component . $$ . callbacks [ message ] = [ options . callbacks ! [ message ] ]
141+ } )
142+ }
143+
144+ return cy . wrap ( component )
145+ } )
146146 } )
147147}
148148
0 commit comments