@@ -21,6 +21,7 @@ import {
2121 Transition ,
2222 TransitionService ,
2323 TypedMap ,
24+ UIViewPortalRenderCommand ,
2425 unnestR ,
2526 ViewService ,
2627} from '@uirouter/core' ;
@@ -213,7 +214,6 @@ uiView = [
213214 } ;
214215
215216 const directive = {
216- count : 0 ,
217217 restrict : 'ECA' ,
218218 terminal : true ,
219219 priority : 400 ,
@@ -228,44 +228,49 @@ uiView = [
228228
229229 let previousEl : JQuery , currentEl : JQuery , currentScope : IScope , viewConfig : Ng1ViewConfig ;
230230
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+
231238 const activeUIView : ActiveUIView = {
232239 $type : 'ng1' ,
233- id : directive . count ++ , // Global sequential ID for ui-view tags added to DOM
240+ id : uiViewId , // filled in later
234241 name : name , // ui-view name (<div ui-view="name"></div>
235242 fqn : inherited . $uiView . fqn ? inherited . $uiView . fqn + '.' + name : name , // fully qualified name, describes location in DOM
236243 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+ // },
246255 } ;
247256
248257 trace . traceUIViewEvent ( 'Linking' , activeUIView ) ;
249258
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+ }
254266
255- viewConfig = config ;
256- updateView ( config ) ;
267+ updateView ( viewConfig ) ;
257268 }
258269
259270 $element . data ( '$uiView' , { $uiView : activeUIView } ) ;
260271
261272 updateView ( ) ;
262273
263- const unregister = $view . registerUIView ( activeUIView ) ;
264- scope . $on ( '$destroy' , function ( ) {
265- trace . traceUIViewEvent ( 'Destroying/Unregistering' , activeUIView ) ;
266- unregister ( ) ;
267- } ) ;
268-
269274 function cleanupLastView ( ) {
270275 if ( previousEl ) {
271276 trace . traceUIViewEvent ( 'Removing (previous) el' , previousEl . data ( '$uiView' ) ) ;
0 commit comments