Skip to content

Commit

Permalink
feat: update to uirouter/core 7.0.0-beta.2
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Aug 8, 2020
1 parent b4c703d commit e814398
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
46 changes: 22 additions & 24 deletions src/directives/viewDirective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,11 @@ uiView = [
inherited = $element.inheritedData('$uiView') || rootData,
name = $interpolate(attrs['uiView'] || attrs['name'] || '')(scope) || '$default';

let previousEl: JQuery, currentEl: JQuery, currentScope: IScope, viewConfig: Ng1ViewConfig;

const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal);

scope.$on('$destroy', function () {
trace.traceUIViewEvent('Destroying/Unregistering', activeUIView);
$view.deregisterView(uiViewId);
});
let previousEl: JQuery, currentEl: JQuery, currentScope: IScope;

const activeUIView: ActiveUIView = {
$type: 'ng1',
id: uiViewId, // filled in later
id: null, // filled in later
name: name, // ui-view name (<div ui-view="name"></div>
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)
Expand All @@ -255,22 +248,15 @@ uiView = [
};

trace.traceUIViewEvent('Linking', activeUIView);
const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal);

function renderContentIntoUIViewPortal(renderCommand: UIViewPortalRenderCommand) {
if (renderCommand.command === 'RENDER_DEFAULT_CONTENT') {
viewConfig = undefined;
} else if (renderCommand.command === 'RENDER_ROUTED_VIEW') {
viewConfig = renderCommand.routedViewConfig as Ng1ViewConfig;
} else if (renderCommand.command === 'RENDER_INTEROP_DIV') {
}

updateView(viewConfig);
}
scope.$on('$destroy', function () {
trace.traceUIViewEvent('Destroying/Unregistering', activeUIView);
$view.deregisterView(uiViewId);
});

$element.data('$uiView', { $uiView: activeUIView });

updateView();

function cleanupLastView() {
if (previousEl) {
trace.traceUIViewEvent('Removing (previous) el', previousEl.data('$uiView'));
Expand All @@ -297,13 +283,25 @@ uiView = [
}
}

function updateView(config?: Ng1ViewConfig) {
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)
: undefined;

const newScope = scope.$new();
const animEnter = $q.defer(),
animLeave = $q.defer();

const $uiViewData: UIViewData = {
$cfg: config,
$cfg: viewConfig,
$uiView: activeUIView,
};

Expand Down Expand Up @@ -354,7 +352,7 @@ uiView = [
*
* @param {Object} event Event object.
*/
currentScope.$emit('$viewContentLoaded', config || viewConfig);
currentScope.$emit('$viewContentLoaded', viewConfig);
currentScope.$eval(onloadExp);
}
};
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "2.5.3"
Expand Down

0 comments on commit e814398

Please sign in to comment.