@angular-wave/angular.ts 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -12
- package/index.html +3 -74
- package/package.json +1 -1
- package/src/angular.spec.js +5 -0
- package/src/animations/animate-css.js +13 -5
- package/src/animations/animate-queue.js +21 -22
- package/src/animations/animate-runner.js +8 -4
- package/src/animations/animate.md +1 -1
- package/src/animations/animate.spec.js +21 -0
- package/src/animations/animation.js +1 -1
- package/src/binding.spec.js +1 -0
- package/src/core/compile/compile.js +26 -25
- package/src/core/compile/compile.spec.js +266 -17
- package/src/core/controller/controller.js +0 -2
- package/src/core/di/injector.md +1 -1
- package/src/core/di/injector.spec.js +2 -0
- package/src/core/di/internal-injector.js +1 -2
- package/src/core/interpolate/interpolate.js +3 -16
- package/src/core/interpolate/interpolate.spec.js +16 -70
- package/src/core/interval/interval-factory.js +50 -0
- package/src/core/interval/interval.html +18 -0
- package/src/core/interval/interval.js +77 -0
- package/src/core/interval/interval.md +123 -0
- package/src/core/interval/interval.spec.js +280 -0
- package/src/core/interval/interval.test.js +1 -1
- package/src/core/location/location.js +47 -39
- package/src/core/location/location.spec.js +27 -27
- package/src/core/on.spec.js +7 -0
- package/src/core/parse/interpreter.js +7 -10
- package/src/core/parse/parse.js +5 -26
- package/src/core/parse/parse.spec.js +91 -95
- package/src/core/prop.spec.js +60 -4
- package/src/core/q/q.html +18 -0
- package/src/core/q/q.js +472 -0
- package/src/core/q/q.md +211 -0
- package/src/core/q/q.spec.js +2748 -0
- package/src/core/q/q.test.js +12 -0
- package/src/core/sce/sce.spec.js +8 -0
- package/src/core/{model/model.html → scope/scope.html} +1 -1
- package/src/core/scope/scope.js +16 -15
- package/src/core/scope/scope.spec.js +1959 -24
- package/src/core/scope/scope.test.js +12 -0
- package/src/core/timeout/timeout.html +18 -0
- package/src/core/timeout/timeout.js +109 -0
- package/src/core/timeout/timeout.spec.js +354 -0
- package/src/core/timeout/timout.test.js +12 -0
- package/src/core/url-utils/url-utils.spec.js +1 -1
- package/src/directive/aria/aria.js +6 -3
- package/src/directive/aria/aria.spec.js +87 -0
- package/src/directive/attrs/attrs.spec.js +5 -0
- package/src/directive/attrs/boolean.spec.js +15 -0
- package/src/directive/attrs/element-style.spec.js +8 -0
- package/src/directive/attrs/src.spec.js +7 -0
- package/src/directive/bind/bind.spec.js +33 -0
- package/src/directive/bind/bing-html.spec.js +3 -0
- package/src/directive/class/class.js +3 -3
- package/src/directive/class/class.spec.js +75 -9
- package/src/directive/controller/controller.spec.js +13 -0
- package/src/directive/events/click.spec.js +3 -0
- package/src/directive/events/event.spec.js +6 -0
- package/src/directive/form/form.js +3 -2
- package/src/directive/form/form.spec.js +65 -0
- package/src/directive/if/if.spec.js +4 -0
- package/src/directive/include/include.spec.js +59 -8
- package/src/directive/init/init.js +2 -6
- package/src/directive/init/init.spec.js +2 -0
- package/src/directive/input/input.spec.js +136 -0
- package/src/directive/messages/messages.spec.js +35 -4
- package/src/directive/model/model.js +25 -18
- package/src/directive/model/model.spec.js +49 -2
- package/src/directive/model-options/model-options.spec.js +6 -0
- package/src/directive/non-bindable/non-bindable.spec.js +1 -0
- package/src/directive/observe/observe.js +1 -0
- package/src/directive/observe/observe.spec.js +1 -0
- package/src/directive/options/options.spec.js +34 -0
- package/src/directive/ref/href.spec.js +15 -0
- package/src/directive/repeat/repeat.spec.js +135 -8
- package/src/directive/script/script.spec.js +2 -0
- package/src/directive/select/select.js +3 -3
- package/src/directive/select/select.spec.js +96 -0
- package/src/directive/show-hide/show-hide.js +2 -2
- package/src/directive/show-hide/show-hide.spec.js +19 -8
- package/src/directive/style/style.spec.js +7 -0
- package/src/directive/switch/switch.spec.js +5 -5
- package/src/directive/validators/validators.spec.js +1 -0
- package/src/loader.js +1 -0
- package/src/public.js +10 -2
- package/src/router/common/coreservices.js +2 -0
- package/src/router/directives/state-directives.js +14 -6
- package/src/router/directives/state-directives.spec.js +83 -0
- package/src/router/directives/view-directive.js +13 -4
- package/src/router/directives/view-directive.spec.js +71 -25
- package/src/router/hooks/lazy-load.js +2 -2
- package/src/router/hooks/views.js +5 -3
- package/src/router/resolve/resolvable.js +6 -3
- package/src/router/resolve/resolve-context.js +2 -2
- package/src/router/state/state-service.js +4 -4
- package/src/router/state/state.spec.js +5 -2
- package/src/router/state/state.test.js +1 -1
- package/src/router/state/views.js +10 -7
- package/src/router/template-factory.js +6 -3
- package/src/router/template-factory.spec.js +4 -0
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/transition/transition.js +1 -1
- package/src/router/view-hook.spec.js +2 -2
- package/src/router/view-scroll.js +6 -4
- package/src/services/browser.js +5 -8
- package/src/services/http/http.js +9 -6
- package/src/services/http/http.spec.js +31 -30
- package/src/services/http/template-request.spec.js +10 -0
- package/src/services/http-backend/http-backend.spec.js +3 -3
- package/src/services/template-request.js +4 -2
- package/src/shared/common.js +2 -1
- package/types/core/location/location.d.ts +36 -31
- package/types/core/parse/parse.d.ts +0 -26
- package/types/core/scope/scope.d.ts +11 -11
- package/src/core/model/model.js +0 -944
- package/src/core/model/model.spec.js +0 -3012
- package/types/core/model/model.d.ts +0 -204
|
@@ -24,31 +24,37 @@ describe("ng-style", () => {
|
|
|
24
24
|
|
|
25
25
|
it("should set", () => {
|
|
26
26
|
element = $compile("<div ng-style=\"{height: '40px'}\"></div>")($scope);
|
|
27
|
+
$scope.$digest();
|
|
27
28
|
expect(element[0].style.height).toEqual("40px");
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
it("should silently ignore undefined style", () => {
|
|
31
32
|
element = $compile('<div ng-style="myStyle"></div>')($scope);
|
|
33
|
+
$scope.$digest();
|
|
32
34
|
expect(element[0].classList.contains("ng-exception")).toBeFalsy();
|
|
33
35
|
});
|
|
34
36
|
|
|
35
37
|
it("should not deep watch objects", () => {
|
|
36
38
|
element = $compile('<div ng-style="{height: heightObj}"></div>')($scope);
|
|
39
|
+
$scope.$digest();
|
|
37
40
|
expect(parseInt(element[0].style.height + 0, 10)).toEqual(0); // height could be '' or '0px'
|
|
38
41
|
$scope.heightObj = {
|
|
39
42
|
toString() {
|
|
40
43
|
return "40px";
|
|
41
44
|
},
|
|
42
45
|
};
|
|
46
|
+
$scope.$digest();
|
|
43
47
|
expect(element[0].style.height).toBe("40px");
|
|
44
48
|
|
|
45
49
|
element[0].style.height = "10px";
|
|
46
50
|
$scope.heightObj.otherProp = 123;
|
|
51
|
+
$scope.$digest();
|
|
47
52
|
expect(element[0].style.height).toBe("10px");
|
|
48
53
|
});
|
|
49
54
|
|
|
50
55
|
it("should support binding for object literals", () => {
|
|
51
56
|
element = $compile('<div ng-style="{height: heightStr}"></div>')($scope);
|
|
57
|
+
$scope.$digest();
|
|
52
58
|
expect(parseInt(element[0].style.height + 0, 10)).toEqual(0); // height could be '' or '0px'
|
|
53
59
|
$scope.$apply('heightStr = "40px"');
|
|
54
60
|
expect(element[0].style.height).toBe("40px");
|
|
@@ -59,6 +65,7 @@ describe("ng-style", () => {
|
|
|
59
65
|
|
|
60
66
|
it("should support lazy one-time binding for object literals", () => {
|
|
61
67
|
element = $compile('<div ng-style="::{height: heightStr}"></div>')($scope);
|
|
68
|
+
$scope.$digest();
|
|
62
69
|
expect(parseInt(element[0].style.height + 0, 10)).toEqual(0); // height could be '' or '0px'
|
|
63
70
|
$scope.$apply('heightStr = "40px"');
|
|
64
71
|
expect(element[0].style.height).toBe("40px");
|
|
@@ -570,9 +570,9 @@ describe("ngSwitch", () => {
|
|
|
570
570
|
// ),
|
|
571
571
|
// )($scope);
|
|
572
572
|
|
|
573
|
-
// ; // re-enable the animations;
|
|
573
|
+
// $rootScope.$digest(); // re-enable the animations;
|
|
574
574
|
// $scope.val = "one";
|
|
575
|
-
// ;
|
|
575
|
+
// $scope.$digest();
|
|
576
576
|
|
|
577
577
|
// item = $animate.queue.shift();
|
|
578
578
|
// expect(item.event).toBe("enter");
|
|
@@ -596,16 +596,16 @@ describe("ngSwitch", () => {
|
|
|
596
596
|
// ),
|
|
597
597
|
// )($scope);
|
|
598
598
|
|
|
599
|
-
// ; // re-enable the animations;
|
|
599
|
+
// $rootScope.$digest(); // re-enable the animations;
|
|
600
600
|
// $scope.val = "two";
|
|
601
|
-
// ;
|
|
601
|
+
// $scope.$digest();
|
|
602
602
|
|
|
603
603
|
// item = $animate.queue.shift();
|
|
604
604
|
// expect(item.event).toBe("enter");
|
|
605
605
|
// expect(item.element.text()).toBe("two");
|
|
606
606
|
|
|
607
607
|
// $scope.val = "three";
|
|
608
|
-
// ;
|
|
608
|
+
// $scope.$digest();
|
|
609
609
|
|
|
610
610
|
// item = $animate.queue.shift();
|
|
611
611
|
// expect(item.event).toBe("leave");
|
package/src/loader.js
CHANGED
|
@@ -152,6 +152,7 @@ export class Angular {
|
|
|
152
152
|
});
|
|
153
153
|
// ng-route deps
|
|
154
154
|
services.$injector = $injector;
|
|
155
|
+
services.$q = $injector.get("$q");
|
|
155
156
|
// https://github.com/angular-ui/ui-router/issues/3678
|
|
156
157
|
if (!Object.prototype.hasOwnProperty.call($injector, "strictDi")) {
|
|
157
158
|
try {
|
package/src/public.js
CHANGED
|
@@ -62,7 +62,9 @@ import { TemplateCacheProvider } from "./core/cache/cache-factory.js";
|
|
|
62
62
|
import { ControllerProvider } from "./core/controller/controller.js";
|
|
63
63
|
import { ExceptionHandlerProvider } from "./core/exception-handler.js";
|
|
64
64
|
import { FilterProvider } from "./core/filter/filter.js";
|
|
65
|
+
import { IntervalProvider } from "./core/interval/interval.js";
|
|
65
66
|
import { InterpolateProvider } from "./core/interpolate/interpolate.js";
|
|
67
|
+
import { $IntervalFactoryProvider } from "./core/interval/interval-factory.js";
|
|
66
68
|
import {
|
|
67
69
|
HttpProvider,
|
|
68
70
|
HttpParamSerializerProvider,
|
|
@@ -71,10 +73,12 @@ import { HttpBackendProvider } from "./services/http-backend/http-backend.js";
|
|
|
71
73
|
import { LocationProvider } from "./core/location/location.js";
|
|
72
74
|
import { LogProvider } from "./services/log.js";
|
|
73
75
|
import { ParseProvider } from "./core/parse/parse.js";
|
|
74
|
-
import {
|
|
76
|
+
import { RootScopeProvider } from "./core/scope/scope.js";
|
|
77
|
+
import { $QProvider } from "./core/q/q.js";
|
|
75
78
|
import { SceProvider, SceDelegateProvider } from "./core/sce/sce.js";
|
|
76
79
|
import { TaskTrackerFactoryProvider } from "./core/task-tracker-factory.js";
|
|
77
80
|
import { TemplateRequestProvider } from "./services/template-request.js";
|
|
81
|
+
import { TimeoutProvider } from "./core/timeout/timeout.js";
|
|
78
82
|
import { SanitizeUriProvider } from "./core/sanitize/sanitize-uri.js";
|
|
79
83
|
import {
|
|
80
84
|
ngMessageDefaultDirective,
|
|
@@ -248,6 +252,8 @@ export function publishExternalAPI(angular) {
|
|
|
248
252
|
$exceptionHandler: ExceptionHandlerProvider,
|
|
249
253
|
$filter: FilterProvider,
|
|
250
254
|
$interpolate: InterpolateProvider,
|
|
255
|
+
$interval: IntervalProvider,
|
|
256
|
+
$$intervalFactory: $IntervalFactoryProvider,
|
|
251
257
|
$http: HttpProvider,
|
|
252
258
|
$httpParamSerializer: HttpParamSerializerProvider,
|
|
253
259
|
$httpBackend: HttpBackendProvider,
|
|
@@ -255,13 +261,15 @@ export function publishExternalAPI(angular) {
|
|
|
255
261
|
$log: LogProvider,
|
|
256
262
|
$parse: ParseProvider,
|
|
257
263
|
$$rAFScheduler: RafSchedulerProvider,
|
|
258
|
-
$rootScope:
|
|
264
|
+
$rootScope: RootScopeProvider,
|
|
259
265
|
$routerGlobals: UIRouterGlobals,
|
|
266
|
+
$q: $QProvider,
|
|
260
267
|
$sce: SceProvider,
|
|
261
268
|
$sceDelegate: SceDelegateProvider,
|
|
262
269
|
$$taskTrackerFactory: TaskTrackerFactoryProvider,
|
|
263
270
|
$templateCache: TemplateCacheProvider,
|
|
264
271
|
$templateRequest: TemplateRequestProvider,
|
|
272
|
+
$timeout: TimeoutProvider,
|
|
265
273
|
$urlConfig: UrlConfigProvider,
|
|
266
274
|
$view: ViewService,
|
|
267
275
|
$transitions: TransitionProvider,
|
|
@@ -43,7 +43,7 @@ function getTypeInfo(el) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
/** @ignore */
|
|
46
|
-
function clickHook(el, $state, type, getDef) {
|
|
46
|
+
function clickHook(el, $state, $timeout, type, getDef) {
|
|
47
47
|
return function (e) {
|
|
48
48
|
const button = e.which || e.button,
|
|
49
49
|
target = getDef();
|
|
@@ -57,7 +57,7 @@ function clickHook(el, $state, type, getDef) {
|
|
|
57
57
|
el.attr("target");
|
|
58
58
|
if (!res) {
|
|
59
59
|
// HACK: This is to allow ng-clicks to be processed before the transition is initiated:
|
|
60
|
-
const transition =
|
|
60
|
+
const transition = $timeout(function () {
|
|
61
61
|
if (!el.attr("disabled")) {
|
|
62
62
|
$state.go(target.ngState, target.ngStateParams, target.ngStateOpts);
|
|
63
63
|
}
|
|
@@ -66,7 +66,7 @@ function clickHook(el, $state, type, getDef) {
|
|
|
66
66
|
// if the state has no URL, ignore one preventDefault from the <a> directive.
|
|
67
67
|
let ignorePreventDefaultCount = type.isAnchor && !target.href ? 1 : 0;
|
|
68
68
|
e.preventDefault = function () {
|
|
69
|
-
if (ignorePreventDefaultCount-- <= 0)
|
|
69
|
+
if (ignorePreventDefaultCount-- <= 0) $timeout.cancel(transition);
|
|
70
70
|
};
|
|
71
71
|
} else {
|
|
72
72
|
// ignored
|
|
@@ -106,9 +106,15 @@ function bindEvents(element, scope, hookFn, ngStateOpts) {
|
|
|
106
106
|
|
|
107
107
|
// // TODO: SEPARATE THESE OUT
|
|
108
108
|
|
|
109
|
-
$StateRefDirective.$inject = [
|
|
109
|
+
$StateRefDirective.$inject = [
|
|
110
|
+
"$state",
|
|
111
|
+
"$timeout",
|
|
112
|
+
"$stateRegistry",
|
|
113
|
+
"$transitions",
|
|
114
|
+
];
|
|
110
115
|
export function $StateRefDirective(
|
|
111
116
|
$stateService,
|
|
117
|
+
$timeout,
|
|
112
118
|
$stateRegistry,
|
|
113
119
|
$transitions,
|
|
114
120
|
) {
|
|
@@ -149,7 +155,7 @@ export function $StateRefDirective(
|
|
|
149
155
|
scope.$on("$destroy", $stateRegistry.onStatesChanged(update));
|
|
150
156
|
scope.$on("$destroy", $transitions.onSuccess({}, update));
|
|
151
157
|
if (!type.clickable) return;
|
|
152
|
-
const hookFn = clickHook(element, $state, type, getDef);
|
|
158
|
+
const hookFn = clickHook(element, $state, $timeout, type, getDef);
|
|
153
159
|
bindEvents(element, scope, hookFn, rawDef.ngStateOpts);
|
|
154
160
|
},
|
|
155
161
|
};
|
|
@@ -157,11 +163,13 @@ export function $StateRefDirective(
|
|
|
157
163
|
|
|
158
164
|
$StateRefDynamicDirective.$inject = [
|
|
159
165
|
"$state",
|
|
166
|
+
"$timeout",
|
|
160
167
|
"$stateRegistry",
|
|
161
168
|
"$transitions",
|
|
162
169
|
];
|
|
163
170
|
export function $StateRefDynamicDirective(
|
|
164
171
|
$state,
|
|
172
|
+
$timeout,
|
|
165
173
|
$stateRegistry,
|
|
166
174
|
$transitions,
|
|
167
175
|
) {
|
|
@@ -205,7 +213,7 @@ export function $StateRefDynamicDirective(
|
|
|
205
213
|
scope.$on("$destroy", $stateRegistry.onStatesChanged(update));
|
|
206
214
|
scope.$on("$destroy", $transitions.onSuccess({}, update));
|
|
207
215
|
if (!type.clickable) return;
|
|
208
|
-
hookFn = clickHook(element, $state, type, getDef);
|
|
216
|
+
hookFn = clickHook(element, $state, $timeout, type, getDef);
|
|
209
217
|
bindEvents(element, scope, hookFn, rawDef.ngStateOpts);
|
|
210
218
|
},
|
|
211
219
|
};
|
|
@@ -50,8 +50,10 @@ describe("ngStateRef", () => {
|
|
|
50
50
|
$injector = window.angular.bootstrap(document.getElementById("dummy"), [
|
|
51
51
|
"defaultModule",
|
|
52
52
|
]);
|
|
53
|
+
$q = $injector.get("$q");
|
|
53
54
|
$rootScope = $injector.get("$rootScope");
|
|
54
55
|
$compile = $injector.get("$compile");
|
|
56
|
+
$timeout = $injector.get("$timeout");
|
|
55
57
|
$state = $injector.get("$state");
|
|
56
58
|
$stateParams = $injector.get("$stateParams");
|
|
57
59
|
$urlService = $injector.get("$urlService");
|
|
@@ -72,6 +74,7 @@ describe("ngStateRef", () => {
|
|
|
72
74
|
defer.resolve({ id: 6 });
|
|
73
75
|
el = $compile(el)($rootScope);
|
|
74
76
|
|
|
77
|
+
$rootScope.$digest();
|
|
75
78
|
expect(el.attr("href")).toBe("#/contacts/6");
|
|
76
79
|
});
|
|
77
80
|
});
|
|
@@ -88,6 +91,7 @@ describe("ngStateRef", () => {
|
|
|
88
91
|
|
|
89
92
|
$compile(el)(scope);
|
|
90
93
|
$compile(el2)(scope);
|
|
94
|
+
scope.$digest();
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
describe("links", () => {
|
|
@@ -114,6 +118,7 @@ describe("ngStateRef", () => {
|
|
|
114
118
|
$rootScope.$apply();
|
|
115
119
|
|
|
116
120
|
$compile(el)($rootScope);
|
|
121
|
+
$rootScope.$digest();
|
|
117
122
|
expect(el.attr("href")).toBe("#/contacts/3");
|
|
118
123
|
});
|
|
119
124
|
|
|
@@ -189,8 +194,12 @@ describe("ngStateRef", () => {
|
|
|
189
194
|
it("should allow passing params to current state", async () => {
|
|
190
195
|
$state.go("other", { id: "abc" });
|
|
191
196
|
$rootScope.$index = "def";
|
|
197
|
+
$rootScope.$digest();
|
|
198
|
+
|
|
192
199
|
el = JQLite('<a ng-sref="{id: $index}">Details</a>');
|
|
193
200
|
$compile(el)($rootScope);
|
|
201
|
+
$rootScope.$digest();
|
|
202
|
+
|
|
194
203
|
expect($state.current.name).toBe("other");
|
|
195
204
|
expect($state.params.id).toEqual("abc");
|
|
196
205
|
expect(el.attr("href")).toBe("#/other/def");
|
|
@@ -202,6 +211,8 @@ describe("ngStateRef", () => {
|
|
|
202
211
|
|
|
203
212
|
$rootScope.$index = "ghi";
|
|
204
213
|
$state.go("other.detail");
|
|
214
|
+
$rootScope.$digest();
|
|
215
|
+
|
|
205
216
|
expect($state.current.name).toBe("other.detail");
|
|
206
217
|
expect($state.params.id).toEqual("def");
|
|
207
218
|
|
|
@@ -215,11 +226,14 @@ describe("ngStateRef", () => {
|
|
|
215
226
|
|
|
216
227
|
it("should allow multi-line attribute values when passing params to current state", async () => {
|
|
217
228
|
$state.go("contacts.item.detail", { id: "123" });
|
|
229
|
+
$rootScope.$digest();
|
|
230
|
+
|
|
218
231
|
el = JQLite('<a ng-sref="{\n\tid: $index\n}">Details</a>');
|
|
219
232
|
$rootScope.$index = 3;
|
|
220
233
|
$rootScope.$apply();
|
|
221
234
|
|
|
222
235
|
$compile(el)($rootScope);
|
|
236
|
+
$rootScope.$digest();
|
|
223
237
|
expect(el.attr("href")).toBe("#/contacts/3");
|
|
224
238
|
});
|
|
225
239
|
|
|
@@ -230,11 +244,13 @@ describe("ngStateRef", () => {
|
|
|
230
244
|
template = $compile(el)($rootScope);
|
|
231
245
|
|
|
232
246
|
$rootScope.urlParams = { id: 1 };
|
|
247
|
+
$rootScope.$digest();
|
|
233
248
|
expect(JQLite(template[0].querySelector("a")).attr("href")).toBe(
|
|
234
249
|
"#/contacts/1",
|
|
235
250
|
);
|
|
236
251
|
|
|
237
252
|
$rootScope.urlParams.id = 2;
|
|
253
|
+
$rootScope.$digest();
|
|
238
254
|
expect(JQLite(template[0].querySelector("a")).attr("href")).toBe(
|
|
239
255
|
"#/contacts/2",
|
|
240
256
|
);
|
|
@@ -284,6 +300,7 @@ describe("ngStateRef", () => {
|
|
|
284
300
|
scope = $rootScope;
|
|
285
301
|
Object.assign(scope, { state: "contacts", params: {} });
|
|
286
302
|
template = $compile(el)(scope);
|
|
303
|
+
scope.$digest();
|
|
287
304
|
});
|
|
288
305
|
|
|
289
306
|
it("sets the correct initial href", () => {
|
|
@@ -295,9 +312,11 @@ describe("ngStateRef", () => {
|
|
|
295
312
|
|
|
296
313
|
scope.state = "contacts.item";
|
|
297
314
|
scope.params = { id: 5 };
|
|
315
|
+
scope.$digest();
|
|
298
316
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts/5");
|
|
299
317
|
|
|
300
318
|
scope.params.id = 25;
|
|
319
|
+
scope.$digest();
|
|
301
320
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts/25");
|
|
302
321
|
});
|
|
303
322
|
|
|
@@ -306,26 +325,31 @@ describe("ngStateRef", () => {
|
|
|
306
325
|
expect(template[0].className).not.toContain("activeeq");
|
|
307
326
|
|
|
308
327
|
$state.go("contacts");
|
|
328
|
+
scope.$digest();
|
|
309
329
|
await wait(100);
|
|
310
330
|
expect(template[0].className).toContain("active activeeq");
|
|
311
331
|
|
|
312
332
|
scope.state = "contacts.item";
|
|
313
333
|
scope.params = { id: 5 };
|
|
334
|
+
scope.$digest();
|
|
314
335
|
await wait(100);
|
|
315
336
|
expect(template[0].className).not.toContain("active");
|
|
316
337
|
expect(template[0].className).not.toContain("activeeq");
|
|
317
338
|
|
|
318
339
|
$state.go("contacts.item", { id: -5 });
|
|
340
|
+
scope.$digest();
|
|
319
341
|
await wait(100);
|
|
320
342
|
expect(template[0].className).not.toContain("active");
|
|
321
343
|
expect(template[0].className).not.toContain("activeeq");
|
|
322
344
|
|
|
323
345
|
$state.go("contacts.item", { id: 5 });
|
|
346
|
+
scope.$digest();
|
|
324
347
|
await wait(100);
|
|
325
348
|
expect(template[0].className).toContain("active activeeq");
|
|
326
349
|
|
|
327
350
|
scope.state = "contacts";
|
|
328
351
|
scope.params = {};
|
|
352
|
+
scope.$digest();
|
|
329
353
|
await wait(100);
|
|
330
354
|
expect(template[0].className).toContain("active");
|
|
331
355
|
expect(template[0].className).not.toContain("activeeq");
|
|
@@ -335,12 +359,15 @@ describe("ngStateRef", () => {
|
|
|
335
359
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts");
|
|
336
360
|
scope.state = "other";
|
|
337
361
|
scope.params = { id: "123" };
|
|
362
|
+
scope.$digest();
|
|
338
363
|
expect(JQLite(template[0]).attr("href")).toBe("#/other/123");
|
|
339
364
|
});
|
|
340
365
|
|
|
341
366
|
it("should allow passing params to current state using empty ng-state", async () => {
|
|
342
367
|
await $state.go("other", { id: "abc" });
|
|
343
368
|
$rootScope.$index = "def";
|
|
369
|
+
$rootScope.$digest();
|
|
370
|
+
|
|
344
371
|
el = JQLite('<a ng-state="" ng-state-params="{id: $index}">Details</a>');
|
|
345
372
|
$compile(el)($rootScope);
|
|
346
373
|
|
|
@@ -356,6 +383,8 @@ describe("ngStateRef", () => {
|
|
|
356
383
|
|
|
357
384
|
$rootScope.$index = "ghi";
|
|
358
385
|
await $state.go("other.detail");
|
|
386
|
+
$rootScope.$digest();
|
|
387
|
+
|
|
359
388
|
expect($state.current.name).toBe("other.detail");
|
|
360
389
|
expect($state.params.id).toEqual("def");
|
|
361
390
|
|
|
@@ -371,21 +400,25 @@ describe("ngStateRef", () => {
|
|
|
371
400
|
it("retains the old href if the new points to a non-state", () => {
|
|
372
401
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts");
|
|
373
402
|
scope.state = "nostate";
|
|
403
|
+
scope.$digest();
|
|
374
404
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts");
|
|
375
405
|
});
|
|
376
406
|
|
|
377
407
|
it("accepts param overrides", () => {
|
|
378
408
|
scope.state = "contacts.item";
|
|
379
409
|
scope.params = { id: 10 };
|
|
410
|
+
scope.$digest();
|
|
380
411
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts/10");
|
|
381
412
|
});
|
|
382
413
|
|
|
383
414
|
it("accepts param overrides", () => {
|
|
384
415
|
scope.state = "contacts.item";
|
|
385
416
|
scope.params = { id: 10 };
|
|
417
|
+
scope.$digest();
|
|
386
418
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts/10");
|
|
387
419
|
|
|
388
420
|
scope.params.id = 22;
|
|
421
|
+
scope.$digest();
|
|
389
422
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts/22");
|
|
390
423
|
});
|
|
391
424
|
|
|
@@ -399,9 +432,11 @@ describe("ngStateRef", () => {
|
|
|
399
432
|
scope.state1 = "contacts.item";
|
|
400
433
|
scope.state2 = "other";
|
|
401
434
|
scope.params = { id: 10 };
|
|
435
|
+
scope.$digest();
|
|
402
436
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts/10");
|
|
403
437
|
|
|
404
438
|
scope.exprvar = "state2";
|
|
439
|
+
scope.$digest();
|
|
405
440
|
expect(JQLite(template[0]).attr("href")).toBe("#/other/10");
|
|
406
441
|
});
|
|
407
442
|
|
|
@@ -411,11 +446,13 @@ describe("ngStateRef", () => {
|
|
|
411
446
|
scope.state = "contacts.item";
|
|
412
447
|
scope.params = { id: 10 };
|
|
413
448
|
template = $compile(el)(scope);
|
|
449
|
+
scope.$digest();
|
|
414
450
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts/10");
|
|
415
451
|
|
|
416
452
|
scope.state = "other";
|
|
417
453
|
scope.params = { id: 22 };
|
|
418
454
|
|
|
455
|
+
scope.$digest();
|
|
419
456
|
expect(JQLite(template[0]).attr("href")).toBe("#/contacts/10");
|
|
420
457
|
});
|
|
421
458
|
|
|
@@ -426,6 +463,8 @@ describe("ngStateRef", () => {
|
|
|
426
463
|
scope.state = "contacts";
|
|
427
464
|
scope.opts = { reload: true };
|
|
428
465
|
template = $compile(el)(scope);
|
|
466
|
+
scope.$digest();
|
|
467
|
+
|
|
429
468
|
spyOn($state, "go").and.callFake(function (state, params, options) {
|
|
430
469
|
transitionOptions = options;
|
|
431
470
|
});
|
|
@@ -457,6 +496,8 @@ describe("ngStateRef", () => {
|
|
|
457
496
|
|
|
458
497
|
scope.state = "contacts";
|
|
459
498
|
$compile(el)(scope);
|
|
499
|
+
scope.$digest();
|
|
500
|
+
|
|
460
501
|
browserTrigger(el, "change");
|
|
461
502
|
await wait(100);
|
|
462
503
|
|
|
@@ -470,11 +511,15 @@ describe("ngStateRef", () => {
|
|
|
470
511
|
|
|
471
512
|
scope.state = "contacts";
|
|
472
513
|
$compile(el)(scope);
|
|
514
|
+
scope.$digest();
|
|
515
|
+
|
|
473
516
|
browserTrigger(el, "change");
|
|
474
517
|
await wait(100);
|
|
475
518
|
expect($state.current.name).toEqual("contacts");
|
|
476
519
|
|
|
477
520
|
$state.go("top");
|
|
521
|
+
scope.$digest();
|
|
522
|
+
|
|
478
523
|
expect($state.current.name).toEqual("top");
|
|
479
524
|
|
|
480
525
|
browserTrigger(el, "blur");
|
|
@@ -490,11 +535,15 @@ describe("ngStateRef", () => {
|
|
|
490
535
|
|
|
491
536
|
scope.state = "contacts";
|
|
492
537
|
$compile(el)(scope);
|
|
538
|
+
scope.$digest();
|
|
539
|
+
|
|
493
540
|
browserTrigger(el, "mouseover");
|
|
494
541
|
await wait(100);
|
|
495
542
|
expect($state.current.name).toEqual("contacts");
|
|
496
543
|
|
|
497
544
|
$state.go("top");
|
|
545
|
+
scope.$digest();
|
|
546
|
+
|
|
498
547
|
expect($state.current.name).toEqual("top");
|
|
499
548
|
|
|
500
549
|
browserTrigger(el, "mousedown");
|
|
@@ -516,6 +565,7 @@ describe("ngStateRef", () => {
|
|
|
516
565
|
scope.$apply();
|
|
517
566
|
|
|
518
567
|
$compile(el)(scope);
|
|
568
|
+
scope.$digest();
|
|
519
569
|
});
|
|
520
570
|
|
|
521
571
|
it("should generate the correct action", () => {
|
|
@@ -587,6 +637,7 @@ describe("ngStateRef", () => {
|
|
|
587
637
|
it("should bind click event by default", async () => {
|
|
588
638
|
el = JQLite('<a ng-sref="contacts"></a>');
|
|
589
639
|
$compile(el)($rootScope);
|
|
640
|
+
$rootScope.$digest();
|
|
590
641
|
expect($state.current.name).toEqual("top");
|
|
591
642
|
|
|
592
643
|
browserTrigger(el, "click");
|
|
@@ -600,6 +651,7 @@ describe("ngStateRef", () => {
|
|
|
600
651
|
'<input type="text" ng-sref="contacts" ng-sref-opts="{ events: [\'change\'] }">',
|
|
601
652
|
);
|
|
602
653
|
$compile(el)($rootScope);
|
|
654
|
+
$rootScope.$digest();
|
|
603
655
|
expect($state.current.name).toEqual("top");
|
|
604
656
|
|
|
605
657
|
browserTrigger(el, "change");
|
|
@@ -613,6 +665,7 @@ describe("ngStateRef", () => {
|
|
|
613
665
|
'<input type="text" ng-sref="contacts" ng-sref-opts="{ events: [\'change\', \'blur\'] }">',
|
|
614
666
|
);
|
|
615
667
|
$compile(el)($rootScope);
|
|
668
|
+
$rootScope.$digest();
|
|
616
669
|
expect($state.current.name).toEqual("top");
|
|
617
670
|
|
|
618
671
|
browserTrigger(el, "change");
|
|
@@ -620,6 +673,8 @@ describe("ngStateRef", () => {
|
|
|
620
673
|
expect($state.current.name).toEqual("contacts");
|
|
621
674
|
|
|
622
675
|
await $state.go("top");
|
|
676
|
+
$rootScope.$digest();
|
|
677
|
+
|
|
623
678
|
expect($state.current.name).toEqual("top");
|
|
624
679
|
|
|
625
680
|
browserTrigger(el, "blur");
|
|
@@ -632,6 +687,7 @@ describe("ngStateRef", () => {
|
|
|
632
687
|
"<a ng-sref=\"contacts\" ng-sref-opts=\"{ events: ['mouseover', 'mousedown'] }\">",
|
|
633
688
|
);
|
|
634
689
|
$compile(el)($rootScope);
|
|
690
|
+
$rootScope.$digest();
|
|
635
691
|
expect($state.current.name).toEqual("top");
|
|
636
692
|
|
|
637
693
|
browserTrigger(el, "mouseover");
|
|
@@ -639,6 +695,8 @@ describe("ngStateRef", () => {
|
|
|
639
695
|
expect($state.current.name).toEqual("contacts");
|
|
640
696
|
|
|
641
697
|
await $state.go("top");
|
|
698
|
+
$rootScope.$digest();
|
|
699
|
+
|
|
642
700
|
expect($state.current.name).toEqual("top");
|
|
643
701
|
|
|
644
702
|
browserTrigger(el, "mousedown");
|
|
@@ -701,8 +759,10 @@ describe("ngSrefActive", () => {
|
|
|
701
759
|
$injector = window.angular.bootstrap(document.getElementById("dummy"), [
|
|
702
760
|
"defaultModule",
|
|
703
761
|
]);
|
|
762
|
+
$q = $injector.get("$q");
|
|
704
763
|
$rootScope = $injector.get("$rootScope");
|
|
705
764
|
$compile = $injector.get("$compile");
|
|
765
|
+
$timeout = $injector.get("$timeout");
|
|
706
766
|
$state = $injector.get("$state");
|
|
707
767
|
$stateParams = $injector.get("$stateParams");
|
|
708
768
|
});
|
|
@@ -712,6 +772,8 @@ describe("ngSrefActive", () => {
|
|
|
712
772
|
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active="active">Contacts</a><a ng-sref="contacts.item({ id: 2 })" ng-sref-active="active">Contacts</a></div>',
|
|
713
773
|
);
|
|
714
774
|
template = $compile(el)($rootScope);
|
|
775
|
+
$rootScope.$digest();
|
|
776
|
+
|
|
715
777
|
expect(JQLite(template[0].querySelector("a")).attr("class")).toBeFalsy();
|
|
716
778
|
$state.transitionTo("contacts.item", { id: 1 });
|
|
717
779
|
await wait(100);
|
|
@@ -727,6 +789,8 @@ describe("ngSrefActive", () => {
|
|
|
727
789
|
'<div><a ng-sref="contacts.item.detail({ foo: \'bar\' })" ng-sref-active="active">Contacts</a></div>',
|
|
728
790
|
);
|
|
729
791
|
template = $compile(el)($rootScope);
|
|
792
|
+
$rootScope.$digest();
|
|
793
|
+
|
|
730
794
|
expect(JQLite(template[0].querySelector("a")).attr("class")).toBeFalsy();
|
|
731
795
|
$state.transitionTo("contacts.item.detail", { id: 5, foo: "bar" });
|
|
732
796
|
await wait(100);
|
|
@@ -743,6 +807,8 @@ describe("ngSrefActive", () => {
|
|
|
743
807
|
'<div><a ng-sref="arrayparam({ foo: [1,2,3] })" ng-sref-active="active">foo 123</a></div>',
|
|
744
808
|
);
|
|
745
809
|
template = $compile(el)($rootScope);
|
|
810
|
+
$rootScope.$digest();
|
|
811
|
+
|
|
746
812
|
expect(JQLite(template[0].querySelector("a")).attr("class")).toBeFalsy();
|
|
747
813
|
|
|
748
814
|
$state.transitionTo("arrayparam", { foo: [1, 2, 3] });
|
|
@@ -764,6 +830,8 @@ describe("ngSrefActive", () => {
|
|
|
764
830
|
'<div><a ng-sref="arrayparam({ foo: [1,2,3] })" ng-sref-active-eq="active">foo 123</a></div>',
|
|
765
831
|
);
|
|
766
832
|
template = $compile(el)($rootScope);
|
|
833
|
+
$rootScope.$digest();
|
|
834
|
+
|
|
767
835
|
expect(JQLite(template[0].querySelector("a")).attr("class")).toBeFalsy();
|
|
768
836
|
|
|
769
837
|
$state.transitionTo("arrayparam", { foo: [1, 2, 3] });
|
|
@@ -785,12 +853,15 @@ describe("ngSrefActive", () => {
|
|
|
785
853
|
);
|
|
786
854
|
template = $compile(el)($rootScope);
|
|
787
855
|
$rootScope.fooId = "bar";
|
|
856
|
+
$rootScope.$digest();
|
|
857
|
+
|
|
788
858
|
expect(JQLite(template[0].querySelector("a")).attr("class")).toBeFalsy();
|
|
789
859
|
$state.transitionTo("contacts.item.detail", { id: 5, foo: "bar" });
|
|
790
860
|
await wait(100);
|
|
791
861
|
expect(JQLite(template[0].querySelector("a")).attr("class")).toBe("active");
|
|
792
862
|
|
|
793
863
|
$rootScope.fooId = "baz";
|
|
864
|
+
$rootScope.$digest();
|
|
794
865
|
await wait(100);
|
|
795
866
|
expect(JQLite(template[0].querySelector("a")).attr("class")).toBeFalsy();
|
|
796
867
|
});
|
|
@@ -799,6 +870,7 @@ describe("ngSrefActive", () => {
|
|
|
799
870
|
template = $compile(
|
|
800
871
|
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active="active">Contacts</a></div>',
|
|
801
872
|
)($rootScope);
|
|
873
|
+
$rootScope.$digest();
|
|
802
874
|
const a = JQLite(template[0].getElementsByTagName("a")[0]);
|
|
803
875
|
|
|
804
876
|
$state.transitionTo("contacts.item.edit", { id: 1 });
|
|
@@ -816,6 +888,7 @@ describe("ngSrefActive", () => {
|
|
|
816
888
|
template = $compile(
|
|
817
889
|
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active-eq="active">Contacts</a></div>',
|
|
818
890
|
)($rootScope);
|
|
891
|
+
$rootScope.$digest();
|
|
819
892
|
const a = JQLite(template[0].getElementsByTagName("a")[0]);
|
|
820
893
|
|
|
821
894
|
$state.transitionTo("contacts.item", { id: 1 });
|
|
@@ -831,6 +904,7 @@ describe("ngSrefActive", () => {
|
|
|
831
904
|
template = $compile(
|
|
832
905
|
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active="active" ng-sref-active-eq="active-eq">Contacts</a></div>',
|
|
833
906
|
)($rootScope);
|
|
907
|
+
$rootScope.$digest();
|
|
834
908
|
const a = JQLite(template[0].getElementsByTagName("a")[0]);
|
|
835
909
|
|
|
836
910
|
$state.transitionTo("contacts.item", { id: 1 });
|
|
@@ -847,6 +921,8 @@ describe("ngSrefActive", () => {
|
|
|
847
921
|
it("should resolve relative state refs", async () => {
|
|
848
922
|
el = JQLite("<section><div ng-view></div></section>");
|
|
849
923
|
template = $compile(el)($rootScope);
|
|
924
|
+
$rootScope.$digest();
|
|
925
|
+
|
|
850
926
|
$state.transitionTo("contacts");
|
|
851
927
|
await wait(100);
|
|
852
928
|
expect(
|
|
@@ -867,6 +943,8 @@ describe("ngSrefActive", () => {
|
|
|
867
943
|
'<div ng-sref-active="active"><a ng-sref="contacts.item({ id: 1 })">Contacts</a><a ng-sref="contacts.item({ id: 2 })">Contacts</a></div>',
|
|
868
944
|
);
|
|
869
945
|
template = $compile(el)($rootScope);
|
|
946
|
+
$rootScope.$digest();
|
|
947
|
+
|
|
870
948
|
expect(JQLite(template[0]).attr("class")).toBeUndefined();
|
|
871
949
|
|
|
872
950
|
$state.transitionTo("contacts.item", { id: 1 });
|
|
@@ -928,6 +1006,7 @@ describe("ngSrefActive", () => {
|
|
|
928
1006
|
template = $compile(
|
|
929
1007
|
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active="active also-active">Contacts</a></div>',
|
|
930
1008
|
)($rootScope);
|
|
1009
|
+
$rootScope.$digest();
|
|
931
1010
|
const a = JQLite(template[0].getElementsByTagName("a")[0]);
|
|
932
1011
|
|
|
933
1012
|
$state.transitionTo("contacts.item.edit", { id: 1 });
|
|
@@ -952,6 +1031,7 @@ describe("ngSrefActive", () => {
|
|
|
952
1031
|
template = $compile(
|
|
953
1032
|
'<div ng-sref-active="active"><a ng-sref="contacts.lazy.s1">Lazy</a></div><div ng-sref-active="active"><a ng-sref="contacts.lazy.s2"></a></div>',
|
|
954
1033
|
)($rootScope);
|
|
1034
|
+
$rootScope.$digest();
|
|
955
1035
|
$state.transitionTo("contacts.lazy.s1");
|
|
956
1036
|
await wait(100);
|
|
957
1037
|
|
|
@@ -1014,6 +1094,7 @@ describe("ngSrefActive", () => {
|
|
|
1014
1094
|
el = $compile("<div ng-sref-active=\"{active: 'admin.roles'}\"/>")(
|
|
1015
1095
|
$rootScope,
|
|
1016
1096
|
);
|
|
1097
|
+
$rootScope.$digest();
|
|
1017
1098
|
timeoutFlush();
|
|
1018
1099
|
expect(el.hasClass("active")).toBeTruthy();
|
|
1019
1100
|
});
|
|
@@ -1034,6 +1115,7 @@ describe("ngSrefActive", () => {
|
|
|
1034
1115
|
template = $compile(
|
|
1035
1116
|
'<div ng-sref-active="{ active: \'contacts.lazy.s1\' }"><a ng-sref="contacts.lazy.s1">Lazy</a></div><div ng-sref-active="{ active: \'contacts.lazy.s2\' }"></div>',
|
|
1036
1117
|
)($rootScope);
|
|
1118
|
+
$rootScope.$digest();
|
|
1037
1119
|
$state.transitionTo("contacts.lazy.s1");
|
|
1038
1120
|
await wait(100);
|
|
1039
1121
|
expect(template.eq(0).hasClass("active")).toBeTruthy();
|
|
@@ -1083,6 +1165,7 @@ describe("ngSrefActive", () => {
|
|
|
1083
1165
|
el = $compile(
|
|
1084
1166
|
"<div ng-sref-active=\"{active: ['admin.roles', 'admin.someOtherState']}\"/>",
|
|
1085
1167
|
)($rootScope);
|
|
1168
|
+
$rootScope.$digest();
|
|
1086
1169
|
timeoutFlush();
|
|
1087
1170
|
expect(el.hasClass("active")).toBeTruthy();
|
|
1088
1171
|
});
|