Skip to content

Commit e814398

Browse files
feat: update to uirouter/core 7.0.0-beta.2
1 parent b4c703d commit e814398

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

src/directives/viewDirective.ts

+22-24
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,11 @@ uiView = [
226226
inherited = $element.inheritedData('$uiView') || rootData,
227227
name = $interpolate(attrs['uiView'] || attrs['name'] || '')(scope) || '$default';
228228

229-
let previousEl: JQuery, currentEl: JQuery, currentScope: IScope, viewConfig: Ng1ViewConfig;
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-
});
229+
let previousEl: JQuery, currentEl: JQuery, currentScope: IScope;
237230

238231
const activeUIView: ActiveUIView = {
239232
$type: 'ng1',
240-
id: uiViewId, // filled in later
233+
id: null, // filled in later
241234
name: name, // ui-view name (<div ui-view="name"></div>
242235
fqn: inherited.$uiView.fqn ? inherited.$uiView.fqn + '.' + name : name, // fully qualified name, describes location in DOM
243236
config: null, // The ViewConfig loaded (from a state.views definition)
@@ -255,22 +248,15 @@ uiView = [
255248
};
256249

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

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-
}
266-
267-
updateView(viewConfig);
268-
}
253+
scope.$on('$destroy', function () {
254+
trace.traceUIViewEvent('Destroying/Unregistering', activeUIView);
255+
$view.deregisterView(uiViewId);
256+
});
269257

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

272-
updateView();
273-
274260
function cleanupLastView() {
275261
if (previousEl) {
276262
trace.traceUIViewEvent('Removing (previous) el', previousEl.data('$uiView'));
@@ -297,13 +283,25 @@ uiView = [
297283
}
298284
}
299285

300-
function updateView(config?: Ng1ViewConfig) {
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;
294+
const viewConfig =
295+
renderCommand.command === 'RENDER_ROUTED_VIEW'
296+
? (renderCommand.routedViewConfig as Ng1ViewConfig)
297+
: undefined;
298+
301299
const newScope = scope.$new();
302300
const animEnter = $q.defer(),
303301
animLeave = $q.defer();
304302

305303
const $uiViewData: UIViewData = {
306-
$cfg: config,
304+
$cfg: viewConfig,
307305
$uiView: activeUIView,
308306
};
309307

@@ -354,7 +352,7 @@ uiView = [
354352
*
355353
* @param {Object} event Event object.
356354
*/
357-
currentScope.$emit('$viewContentLoaded', config || viewConfig);
355+
currentScope.$emit('$viewContentLoaded', viewConfig);
358356
currentScope.$eval(onloadExp);
359357
}
360358
};

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,9 @@
736736
eslint-visitor-keys "^1.1.0"
737737

738738
"@uirouter/core@v7beta":
739-
version "7.0.0-beta.1"
740-
resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.1.tgz#294c9a9f82f203ca396763b470093daeef3a8d52"
741-
integrity sha512-jdRQscId7iHWnuSw9xvWNnTDM8QORqP1J5ovtDPtKEW3m0+SfCcKJqQWV6AyXXBFhUIzF+0JmQ8YOoVxDFSBPw==
739+
version "7.0.0-beta.2"
740+
resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.2.tgz#99669b70ef2b27066cc46f167caa1de1a505dcb9"
741+
integrity sha512-ScY+H1n6lyEP5f78CTZlvc8eT5U5NRac0CAZQhy77ExLE4+zg0djyczsHR+omgNfAUndnSx4tqo+DbgjXZfUlw==
742742

743743
"@uirouter/[email protected]":
744744
version "2.5.3"

0 commit comments

Comments
 (0)