@@ -228,16 +228,9 @@ uiView = [
228
228
229
229
let previousEl : JQuery , currentEl : JQuery , currentScope : IScope ;
230
230
231
- const uiViewId = $view . registerView ( 'ng1' , inherited . $uiView . id , name , renderContentIntoUIViewPortal ) ;
232
-
233
- scope . $on ( '$destroy' , function ( ) {
234
- trace . traceUIViewEvent ( 'Destroying/Unregistering' , activeUIView ) ;
235
- $view . deregisterView ( uiViewId ) ;
236
- } ) ;
237
-
238
231
const activeUIView : ActiveUIView = {
239
232
$type : 'ng1' ,
240
- id : uiViewId , // filled in later
233
+ id : null , // filled in later
241
234
name : name , // ui-view name (<div ui-view="name"></div>
242
235
fqn : inherited . $uiView . fqn ? inherited . $uiView . fqn + '.' + name : name , // fully qualified name, describes location in DOM
243
236
config : null , // The ViewConfig loaded (from a state.views definition)
@@ -255,10 +248,14 @@ uiView = [
255
248
} ;
256
249
257
250
trace . traceUIViewEvent ( 'Linking' , activeUIView ) ;
251
+ const uiViewId = $view . registerView ( 'ng1' , inherited . $uiView . id , name , renderContentIntoUIViewPortal ) ;
258
252
259
- $element . data ( '$uiView' , { $uiView : activeUIView } ) ;
253
+ scope . $on ( '$destroy' , function ( ) {
254
+ trace . traceUIViewEvent ( 'Destroying/Unregistering' , activeUIView ) ;
255
+ $view . deregisterView ( uiViewId ) ;
256
+ } ) ;
260
257
261
- renderContentIntoUIViewPortal ( { command : 'RENDER_DEFAULT_CONTENT' } ) ;
258
+ $element . data ( '$uiView' , { $uiView : activeUIView } ) ;
262
259
263
260
function cleanupLastView ( ) {
264
261
if ( previousEl ) {
@@ -287,6 +284,13 @@ uiView = [
287
284
}
288
285
289
286
function renderContentIntoUIViewPortal ( renderCommand : UIViewPortalRenderCommand ) {
287
+ if ( isString ( activeUIView ) && activeUIView . id !== renderCommand . id ) {
288
+ throw new Error (
289
+ `Received a render command for wrong UIView. Render command id: ${ renderCommand . id } , but this UIView id: ${ activeUIView . id } `
290
+ ) ;
291
+ }
292
+
293
+ activeUIView . id = renderCommand . id ;
290
294
const viewConfig =
291
295
renderCommand . command === 'RENDER_ROUTED_VIEW'
292
296
? ( renderCommand . routedViewConfig as Ng1ViewConfig )
0 commit comments