@@ -21,6 +21,7 @@ import {
21
21
Transition ,
22
22
TransitionService ,
23
23
TypedMap ,
24
+ UIViewPortalRenderCommand ,
24
25
unnestR ,
25
26
ViewService ,
26
27
} from '@uirouter/core' ;
@@ -213,7 +214,6 @@ uiView = [
213
214
} ;
214
215
215
216
const directive = {
216
- count : 0 ,
217
217
restrict : 'ECA' ,
218
218
terminal : true ,
219
219
priority : 400 ,
@@ -228,44 +228,49 @@ uiView = [
228
228
229
229
let previousEl : JQuery , currentEl : JQuery , currentScope : IScope , viewConfig : Ng1ViewConfig ;
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
+
231
238
const activeUIView : ActiveUIView = {
232
239
$type : 'ng1' ,
233
- id : directive . count ++ , // Global sequential ID for ui-view tags added to DOM
240
+ id : uiViewId , // filled in later
234
241
name : name , // ui-view name (<div ui-view="name"></div>
235
242
fqn : inherited . $uiView . fqn ? inherited . $uiView . fqn + '.' + name : name , // fully qualified name, describes location in DOM
236
243
config : null , // The ViewConfig loaded (from a state.views definition)
237
- configUpdated : configUpdatedCallback , // Called when the matching ViewConfig changes
238
- get creationContext ( ) {
239
- // The context in which this ui-view "tag" was created
240
- const fromParentTagConfig = parse ( '$cfg.viewDecl.$context' ) ( inherited ) ;
241
- // Allow <ui-view name="foo"><ui-view name="bar"></ui-view></ui-view>
242
- // See https://github.com/angular-ui/ui-router/issues/3355
243
- const fromParentTag = parse ( '$uiView.creationContext' ) ( inherited ) ;
244
- return fromParentTagConfig || fromParentTag ;
245
- } ,
244
+ configUpdated : undefined , // unused in core
245
+ creationContext : undefined , // unused in core
246
+ // configUpdated: configUpdatedCallback, // Called when the matching ViewConfig changes
247
+ // get creationContext() {
248
+ // The context in which this ui-view "tag" was created
249
+ // const fromParentTagConfig = parse('$cfg.viewDecl.$context')(inherited);
250
+ // Allow <ui-view name="foo"><ui-view name="bar"></ui-view></ui-view>
251
+ // See https://github.com/angular-ui/ui-router/issues/3355
252
+ // const fromParentTag = parse('$uiView.creationContext')(inherited);
253
+ // return fromParentTagConfig || fromParentTag;
254
+ // },
246
255
} ;
247
256
248
257
trace . traceUIViewEvent ( 'Linking' , activeUIView ) ;
249
258
250
- function configUpdatedCallback ( config ?: Ng1ViewConfig ) {
251
- if ( config && ! ( config instanceof Ng1ViewConfig ) ) return ;
252
- if ( configsEqual ( viewConfig , config ) ) return ;
253
- trace . traceUIViewConfigUpdated ( activeUIView , config && config . viewDecl && config . viewDecl . $context ) ;
259
+ function renderContentIntoUIViewPortal ( renderCommand : UIViewPortalRenderCommand ) {
260
+ if ( renderCommand . command === 'RENDER_DEFAULT_CONTENT' ) {
261
+ viewConfig = undefined ;
262
+ } else if ( renderCommand . command === 'RENDER_ROUTED_VIEW' ) {
263
+ viewConfig = renderCommand . routedViewConfig as Ng1ViewConfig ;
264
+ } else if ( renderCommand . command === 'RENDER_INTEROP_DIV' ) {
265
+ }
254
266
255
- viewConfig = config ;
256
- updateView ( config ) ;
267
+ updateView ( viewConfig ) ;
257
268
}
258
269
259
270
$element . data ( '$uiView' , { $uiView : activeUIView } ) ;
260
271
261
272
updateView ( ) ;
262
273
263
- const unregister = $view . registerUIView ( activeUIView ) ;
264
- scope . $on ( '$destroy' , function ( ) {
265
- trace . traceUIViewEvent ( 'Destroying/Unregistering' , activeUIView ) ;
266
- unregister ( ) ;
267
- } ) ;
268
-
269
274
function cleanupLastView ( ) {
270
275
if ( previousEl ) {
271
276
trace . traceUIViewEvent ( 'Removing (previous) el' , previousEl . data ( '$uiView' ) ) ;
0 commit comments