Skip to content

Commit 1d7199f

Browse files
update to 7.0 beta-3
1 parent ad64609 commit 1d7199f

File tree

3 files changed

+52
-18
lines changed

3 files changed

+52
-18
lines changed

src/directives/viewDirective.ts

+48-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @publicapi @module directives */ /** */
22
import {
33
$QLike,
4-
ActiveUIView,
54
extend,
65
filter,
76
HookRegOptions,
@@ -23,8 +22,11 @@ import {
2322
TypedMap,
2423
UIViewPortalRenderCommand,
2524
unnestR,
25+
ViewConfig,
26+
ViewContext,
2627
ViewService,
2728
} from '@uirouter/core';
29+
import { UIViewPortalRegistration } from '@uirouter/core/lib/view/interface';
2830
import { IAugmentedJQuery, IInterpolateService, IScope, ITranscludeFunction } from 'angular';
2931
import { ng as angular } from '../angular';
3032
import { Ng1Controller, Ng1StateDeclaration } from '../interface';
@@ -172,6 +174,26 @@ export type UIViewAnimData = {
172174
* ```
173175
*/
174176
export let uiView: ng1_directive;
177+
178+
// No longer exported from @uirouter/core
179+
// for backwards compat only
180+
export interface ActiveUIView {
181+
/** type of framework, e.g., "ng1" or "ng2" */
182+
$type: string;
183+
/** An auto-incremented id */
184+
id: number | string;
185+
/** The ui-view short name */
186+
name: string;
187+
/** The ui-view's fully qualified name */
188+
fqn: string;
189+
/** The ViewConfig that is currently loaded into the ui-view */
190+
config: ViewConfig;
191+
/** The state context in which the ui-view tag was created. */
192+
creationContext: ViewContext;
193+
/** A callback that should apply a ViewConfig (or clear the ui-view, if config is undefined) */
194+
configUpdated: (config: ViewConfig) => void;
195+
}
196+
175197
// eslint-disable-next-line prefer-const
176198
uiView = [
177199
'$view',
@@ -244,14 +266,22 @@ uiView = [
244266
// },
245267
};
246268

247-
trace.traceUIViewEvent('Linking', activeUIView);
248-
const uiViewId = $view.registerView('ng1', inherited.$uiView.id, name, renderContentIntoUIViewPortal);
269+
const uiViewId = $view._pluginapi._registerView(
270+
'ng1',
271+
inherited.$uiView.id,
272+
name,
273+
renderContentIntoUIViewPortal
274+
);
275+
// as any: trace requires the internal interface, hmmm... this isn't good
276+
const registration = $view._pluginapi._registeredUIView(uiViewId) as any;
277+
trace.traceUIViewEvent('Linking', registration);
249278

250279
scope.$on('$destroy', function () {
251-
trace.traceUIViewEvent('Destroying/Unregistering', activeUIView);
252-
$view.deregisterView(uiViewId);
280+
trace.traceUIViewEvent('Destroying/Unregistering', registration);
281+
$view._pluginapi._deregisterView(uiViewId);
253282
});
254283

284+
// backwards compat
255285
$element.data('$uiView', { $uiView: activeUIView });
256286

257287
function cleanupLastView() {
@@ -262,7 +292,7 @@ uiView = [
262292
}
263293

264294
if (currentScope) {
265-
trace.traceUIViewEvent('Destroying scope', activeUIView);
295+
trace.traceUIViewEvent('Destroying scope', registration);
266296
currentScope.$destroy();
267297
currentScope = null;
268298
}
@@ -281,16 +311,17 @@ uiView = [
281311
}
282312

283313
function renderContentIntoUIViewPortal(renderCommand: UIViewPortalRenderCommand) {
284-
if (isString(activeUIView) && activeUIView.id !== renderCommand.id) {
314+
const renderCmdViewId = renderCommand.uiViewPortalRegistration.id;
315+
if (isString(activeUIView.id) && activeUIView.id !== renderCmdViewId) {
285316
throw new Error(
286-
`Received a render command for wrong UIView. Render command id: ${renderCommand.id}, but this UIView id: ${activeUIView.id}`
317+
`Received a render command for wrong UIView. Render command id: ${renderCmdViewId}, but this UIView id: ${activeUIView.id}`
287318
);
288319
}
289320

290-
activeUIView.id = renderCommand.id;
321+
activeUIView.id = renderCmdViewId;
291322
const viewConfig =
292-
renderCommand.command === 'RENDER_ROUTED_VIEW'
293-
? (renderCommand.routedViewConfig as Ng1ViewConfig)
323+
renderCommand.portalContentType === 'RENDER_ROUTED_VIEW'
324+
? (renderCommand.uiViewPortalRegistration.viewConfig as Ng1ViewConfig)
294325
: undefined;
295326

296327
const newScope = scope.$new();
@@ -384,20 +415,22 @@ function $ViewDirectiveFill(
384415
return function (scope: IScope, $element: JQuery) {
385416
const data: UIViewData = $element.data('$uiView') || {};
386417
const { $renderCommand, $uiView } = data;
387-
if (!$renderCommand || $renderCommand.command === 'RENDER_DEFAULT_CONTENT') {
418+
if (!$renderCommand || $renderCommand.portalContentType === 'RENDER_DEFAULT_CONTENT') {
388419
$element.html(initial);
389420
$compile($element.contents() as any)(scope);
390421
return;
391-
} else if ($renderCommand.command === 'RENDER_INTEROP_DIV') {
422+
} else if ($renderCommand.portalContentType === 'RENDER_INTEROP_DIV') {
392423
$element.html('<div></div>');
393424
$renderCommand.giveDiv($element.find('div')[0]);
394425
return;
395426
}
396427

397-
const cfg: Ng1ViewConfig = $renderCommand.routedViewConfig || ({ viewDecl: {}, getTemplate: noop } as any);
428+
const { uiViewPortalRegistration } = $renderCommand;
429+
const { viewConfig } = uiViewPortalRegistration;
430+
const cfg: Ng1ViewConfig = viewConfig || ({ viewDecl: {}, getTemplate: noop } as any);
398431
const resolveCtx: ResolveContext = cfg.path && new ResolveContext(cfg.path);
399432
$element.html(cfg.getTemplate($element, resolveCtx) || initial);
400-
trace.traceUIViewFill($uiView, $element.html());
433+
trace.traceUIViewFill(uiViewPortalRegistration as any, $element.html());
401434

402435
const link = $compile($element.contents() as any);
403436
const controller = cfg.controller as angular.IControllerService;

test/stateSpec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ describe('state', function () {
928928
$rootScope,
929929
$compile
930930
) {
931+
debugger;
931932
$compile('<div> <div ui-view/></div>')($rootScope);
932933
$state.transitionTo('logA.logB.logC');
933934
$q.flush();

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.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==
739+
version "7.0.0-beta.3"
740+
resolved "https://registry.yarnpkg.com/@uirouter/core/-/core-7.0.0-beta.3.tgz#a4df98267d5aa4f512b545cc1535f20192270f8e"
741+
integrity sha512-T4UT0V2MgadE+Z/ZaB8bc/QhZdvw0foQWWb/BrVCxoKDZJMghxAk7/7PI3KGRTBvJkk+Py0n2INafwGlPH4M+w==
742742

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

0 commit comments

Comments
 (0)