From 0e9e6a9ce79270b9e61ffd4f788ab5324d362d7f Mon Sep 17 00:00:00 2001 From: Chris Thielen Date: Sat, 8 Aug 2020 11:26:47 -0700 Subject: [PATCH] feat: update to uirouter/core 7.0.0-beta.2 --- src/directives/viewDirective.ts | 24 ++++++++++++++---------- yarn.lock | 6 +++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/directives/viewDirective.ts b/src/directives/viewDirective.ts index 49f80b0d7..18ab81b2b 100644 --- a/src/directives/viewDirective.ts +++ b/src/directives/viewDirective.ts @@ -228,16 +228,9 @@ uiView = [ let previousEl: JQuery, currentEl: JQuery, currentScope: IScope; - const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal); - - scope.$on('$destroy', function () { - trace.traceUIViewEvent('Destroying/Unregistering', activeUIView); - $view.deregisterView(uiViewId); - }); - const activeUIView: ActiveUIView = { $type: 'ng1', - id: uiViewId, // filled in later + id: null, // filled in later name: name, // ui-view name (
fqn: inherited.$uiView.fqn ? inherited.$uiView.fqn + '.' + name : name, // fully qualified name, describes location in DOM config: null, // The ViewConfig loaded (from a state.views definition) @@ -255,10 +248,14 @@ uiView = [ }; trace.traceUIViewEvent('Linking', activeUIView); + const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal); - $element.data('$uiView', { $uiView: activeUIView }); + scope.$on('$destroy', function () { + trace.traceUIViewEvent('Destroying/Unregistering', activeUIView); + $view.deregisterView(uiViewId); + }); - renderContentIntoUIViewPortal({ command: 'RENDER_DEFAULT_CONTENT' }); + $element.data('$uiView', { $uiView: activeUIView }); function cleanupLastView() { if (previousEl) { @@ -287,6 +284,13 @@ uiView = [ } function renderContentIntoUIViewPortal(renderCommand: UIViewPortalRenderCommand) { + if (isString(activeUIView) && activeUIView.id !== renderCommand.id) { + throw new Error( + `Received a render command for wrong UIView. Render command id: ${renderCommand.id}, but this UIView id: ${activeUIView.id}` + ); + } + + activeUIView.id = renderCommand.id; const viewConfig = renderCommand.command === 'RENDER_ROUTED_VIEW' ? (renderCommand.routedViewConfig as Ng1ViewConfig) diff --git a/yarn.lock b/yarn.lock index e90bce668..424f1726b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -736,9 +736,9 @@ eslint-visitor-keys "^1.1.0" "@uirouter/core@v7beta": - version "7.0.0-beta.1" - resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.1.tgz#294c9a9f82f203ca396763b470093daeef3a8d52" - integrity sha512-jdRQscId7iHWnuSw9xvWNnTDM8QORqP1J5ovtDPtKEW3m0+SfCcKJqQWV6AyXXBFhUIzF+0JmQ8YOoVxDFSBPw== + version "7.0.0-beta.2" + resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.2.tgz#99669b70ef2b27066cc46f167caa1de1a505dcb9" + integrity sha512-ScY+H1n6lyEP5f78CTZlvc8eT5U5NRac0CAZQhy77ExLE4+zg0djyczsHR+omgNfAUndnSx4tqo+DbgjXZfUlw== "@uirouter/publish-scripts@2.5.3": version "2.5.3"