@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,6 +24,7 @@ describe("ngSrc", () => {
|
|
|
24
24
|
it("should not result empty string in img src", () => {
|
|
25
25
|
$scope.image = {};
|
|
26
26
|
element = $compile('<img ng-src="{{image.url}}">')($scope);
|
|
27
|
+
$scope.$digest();
|
|
27
28
|
expect(element.attr("src")).not.toBe("");
|
|
28
29
|
expect(element.attr("src")).toBeUndefined();
|
|
29
30
|
});
|
|
@@ -31,17 +32,20 @@ describe("ngSrc", () => {
|
|
|
31
32
|
it("should sanitize interpolated url", () => {
|
|
32
33
|
$scope.imageUrl = "javascript:alert(1);";
|
|
33
34
|
element = $compile('<img ng-src="{{imageUrl}}">')($scope);
|
|
35
|
+
$scope.$digest();
|
|
34
36
|
expect(element.attr("src")).toBe("unsafe:javascript:alert(1);");
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
it("should sanitize non-interpolated url", () => {
|
|
38
40
|
element = $compile('<img ng-src="javascript:alert(1);">')($scope);
|
|
41
|
+
$scope.$digest();
|
|
39
42
|
expect(element.attr("src")).toBe("unsafe:javascript:alert(1);");
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
it("should interpolate the expression and bind to src with raw same-domain value", () => {
|
|
43
46
|
element = $compile('<img ng-src="{{id}}"></img>')($scope);
|
|
44
47
|
|
|
48
|
+
$scope.$digest();
|
|
45
49
|
expect(element.attr("src")).toBeUndefined();
|
|
46
50
|
|
|
47
51
|
$scope.$apply(() => {
|
|
@@ -63,11 +67,13 @@ describe("ngSrc", () => {
|
|
|
63
67
|
$scope.imageUrl = "dynamic";
|
|
64
68
|
element = $compile('<img ng-src="{{imageUrl}}" src="static">')($scope);
|
|
65
69
|
expect(element.attr("src")).toBe("static");
|
|
70
|
+
$scope.$digest();
|
|
66
71
|
expect(element.attr("src")).toBe("dynamic");
|
|
67
72
|
dealoc(element);
|
|
68
73
|
|
|
69
74
|
element = $compile('<img src="static" ng-src="{{imageUrl}}">')($scope);
|
|
70
75
|
expect(element.attr("src")).toBe("static");
|
|
76
|
+
$scope.$digest();
|
|
71
77
|
expect(element.attr("src")).toBe("dynamic");
|
|
72
78
|
});
|
|
73
79
|
});
|
|
@@ -129,6 +135,7 @@ describe("ngSrc", () => {
|
|
|
129
135
|
it("should interpolate the expression and bind to src with a trusted value", () => {
|
|
130
136
|
element = $compile('<iframe ng-src="{{id}}"></iframe>')($scope);
|
|
131
137
|
|
|
138
|
+
$scope.$digest();
|
|
132
139
|
expect(element.attr("src")).toBeUndefined();
|
|
133
140
|
|
|
134
141
|
$scope.$apply(() => {
|
|
@@ -35,16 +35,20 @@ describe("ng-bind", () => {
|
|
|
35
35
|
element = $compile('<div ng-bind="a"></div>')($rootScope);
|
|
36
36
|
expect(element.text()).toEqual("");
|
|
37
37
|
$rootScope.a = "misko";
|
|
38
|
+
$rootScope.$digest();
|
|
38
39
|
expect(element.text()).toEqual("misko");
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
it("should set text to blank if undefined", () => {
|
|
42
43
|
element = $compile('<div ng-bind="a"></div>')($rootScope);
|
|
43
44
|
$rootScope.a = "misko";
|
|
45
|
+
$rootScope.$digest();
|
|
44
46
|
expect(element.text()).toEqual("misko");
|
|
45
47
|
$rootScope.a = undefined;
|
|
48
|
+
$rootScope.$digest();
|
|
46
49
|
expect(element.text()).toEqual("");
|
|
47
50
|
$rootScope.a = null;
|
|
51
|
+
$rootScope.$digest();
|
|
48
52
|
expect(element.text()).toEqual("");
|
|
49
53
|
});
|
|
50
54
|
|
|
@@ -57,6 +61,7 @@ describe("ng-bind", () => {
|
|
|
57
61
|
'<span ng-bind="false"></span>' +
|
|
58
62
|
"</div>",
|
|
59
63
|
)($rootScope);
|
|
64
|
+
$rootScope.$digest();
|
|
60
65
|
expect(element.text()).toEqual("-0false");
|
|
61
66
|
});
|
|
62
67
|
|
|
@@ -69,6 +74,7 @@ describe("ng-bind", () => {
|
|
|
69
74
|
() => {
|
|
70
75
|
$rootScope.value = prop[0];
|
|
71
76
|
element = $compile('<div ng-bind="value"></div>')($rootScope);
|
|
77
|
+
$rootScope.$digest();
|
|
72
78
|
expect(element.text()).toEqual(prop[1]);
|
|
73
79
|
};
|
|
74
80
|
});
|
|
@@ -81,18 +87,21 @@ describe("ng-bind", () => {
|
|
|
81
87
|
},
|
|
82
88
|
};
|
|
83
89
|
element = $compile('<div ng-bind="value"></div>')($rootScope);
|
|
90
|
+
$rootScope.$digest();
|
|
84
91
|
expect(element.text()).toEqual("foo");
|
|
85
92
|
});
|
|
86
93
|
|
|
87
94
|
it("should NOT use toString on array objects", () => {
|
|
88
95
|
$rootScope.value = [];
|
|
89
96
|
element = $compile('<div ng-bind="value"></div>')($rootScope);
|
|
97
|
+
$rootScope.$digest();
|
|
90
98
|
expect(element.text()).toEqual("[]");
|
|
91
99
|
});
|
|
92
100
|
|
|
93
101
|
it("should NOT use toString on Date objects", () => {
|
|
94
102
|
$rootScope.value = new Date(2014, 10, 10, 0, 0, 0);
|
|
95
103
|
element = $compile('<div ng-bind="value"></div>')($rootScope);
|
|
104
|
+
$rootScope.$digest();
|
|
96
105
|
expect(element.text()).toBe(JSON.stringify($rootScope.value));
|
|
97
106
|
expect(element.text()).not.toEqual($rootScope.value.toString());
|
|
98
107
|
});
|
|
@@ -101,9 +110,11 @@ describe("ng-bind", () => {
|
|
|
101
110
|
element = $compile('<div ng-bind="::a"></div>')($rootScope);
|
|
102
111
|
$rootScope.a = "lucas";
|
|
103
112
|
expect($rootScope.$$watchers.length).toEqual(1);
|
|
113
|
+
$rootScope.$digest();
|
|
104
114
|
expect(element.text()).toEqual("lucas");
|
|
105
115
|
expect($rootScope.$$watchers.length).toEqual(0);
|
|
106
116
|
$rootScope.a = undefined;
|
|
117
|
+
$rootScope.$digest();
|
|
107
118
|
expect(element.text()).toEqual("lucas");
|
|
108
119
|
});
|
|
109
120
|
|
|
@@ -115,8 +126,10 @@ describe("ng-bind", () => {
|
|
|
115
126
|
}
|
|
116
127
|
});
|
|
117
128
|
$rootScope.a = "foo";
|
|
129
|
+
$rootScope.$digest();
|
|
118
130
|
expect(element.text()).toEqual("bar");
|
|
119
131
|
$rootScope.a = undefined;
|
|
132
|
+
$rootScope.$digest();
|
|
120
133
|
expect(element.text()).toEqual("bar");
|
|
121
134
|
});
|
|
122
135
|
|
|
@@ -128,10 +141,13 @@ describe("ng-bind", () => {
|
|
|
128
141
|
}
|
|
129
142
|
});
|
|
130
143
|
$rootScope.a = "foo";
|
|
144
|
+
$rootScope.$digest();
|
|
131
145
|
expect(element.text()).toEqual("");
|
|
132
146
|
$rootScope.a = "bar";
|
|
147
|
+
$rootScope.$digest();
|
|
133
148
|
expect(element.text()).toEqual("bar");
|
|
134
149
|
$rootScope.a = "man";
|
|
150
|
+
$rootScope.$digest();
|
|
135
151
|
expect(element.text()).toEqual("bar");
|
|
136
152
|
});
|
|
137
153
|
});
|
|
@@ -142,6 +158,7 @@ describe("ng-bind", () => {
|
|
|
142
158
|
$rootScope,
|
|
143
159
|
);
|
|
144
160
|
$rootScope.name = "Misko";
|
|
161
|
+
$rootScope.$digest();
|
|
145
162
|
expect(element.text()).toEqual("Hello Misko!");
|
|
146
163
|
});
|
|
147
164
|
|
|
@@ -151,10 +168,12 @@ describe("ng-bind", () => {
|
|
|
151
168
|
)($rootScope);
|
|
152
169
|
$rootScope.name = "Misko";
|
|
153
170
|
expect($rootScope.$$watchers.length).toEqual(2);
|
|
171
|
+
$rootScope.$digest();
|
|
154
172
|
expect(element.text()).toEqual(" Misko!");
|
|
155
173
|
expect($rootScope.$$watchers.length).toEqual(1);
|
|
156
174
|
$rootScope.hello = "Hello";
|
|
157
175
|
$rootScope.name = "Lucas";
|
|
176
|
+
$rootScope.$digest();
|
|
158
177
|
expect(element.text()).toEqual("Hello Misko!");
|
|
159
178
|
expect($rootScope.$$watchers.length).toEqual(0);
|
|
160
179
|
});
|
|
@@ -163,6 +182,8 @@ describe("ng-bind", () => {
|
|
|
163
182
|
element = $compile('<pre>{{ {key:"value", $$key:"hide"} }}</pre>')(
|
|
164
183
|
$rootScope,
|
|
165
184
|
);
|
|
185
|
+
$rootScope.$digest();
|
|
186
|
+
|
|
166
187
|
expect(JSON.parse(element.text())).toEqual({ key: "value" });
|
|
167
188
|
});
|
|
168
189
|
});
|
|
@@ -171,6 +192,7 @@ describe("ng-bind", () => {
|
|
|
171
192
|
it("should complain about accidental use of interpolation", () => {
|
|
172
193
|
expect(() => {
|
|
173
194
|
$compile('<div ng-bind-html="{{myHtml}}"></div>');
|
|
195
|
+
$rootScope.$digest();
|
|
174
196
|
}).toThrowError(/syntax/);
|
|
175
197
|
});
|
|
176
198
|
|
|
@@ -203,14 +225,17 @@ describe("ng-bind", () => {
|
|
|
203
225
|
it("should set html", () => {
|
|
204
226
|
element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
205
227
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
228
|
+
$rootScope.$digest();
|
|
206
229
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
207
230
|
});
|
|
208
231
|
|
|
209
232
|
it("should update html", () => {
|
|
210
233
|
element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
211
234
|
$rootScope.html = "hello";
|
|
235
|
+
$rootScope.$digest();
|
|
212
236
|
expect(element.html()).toEqual("hello");
|
|
213
237
|
$rootScope.html = "goodbye";
|
|
238
|
+
$rootScope.$digest();
|
|
214
239
|
expect(element.html()).toEqual("goodbye");
|
|
215
240
|
});
|
|
216
241
|
|
|
@@ -218,9 +243,11 @@ describe("ng-bind", () => {
|
|
|
218
243
|
element = $compile('<div ng-bind-html="::html"></div>')($rootScope);
|
|
219
244
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
220
245
|
expect($rootScope.$$watchers.length).toEqual(1);
|
|
246
|
+
$rootScope.$digest();
|
|
221
247
|
expect(element.text()).toEqual("hello");
|
|
222
248
|
expect($rootScope.$$watchers.length).toEqual(0);
|
|
223
249
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
250
|
+
$rootScope.$digest();
|
|
224
251
|
expect(element.text()).toEqual("hello");
|
|
225
252
|
});
|
|
226
253
|
});
|
|
@@ -255,14 +282,17 @@ describe("ng-bind", () => {
|
|
|
255
282
|
it("should set html for trusted values", () => {
|
|
256
283
|
element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
257
284
|
$rootScope.html = $sce.trustAsHtml('<div onclick="">hello</div>');
|
|
285
|
+
$rootScope.$digest();
|
|
258
286
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
259
287
|
});
|
|
260
288
|
|
|
261
289
|
it("should update html", () => {
|
|
262
290
|
element = $compile('<div ng-bind-html="html"></div>')(scope);
|
|
263
291
|
scope.html = $sce.trustAsHtml("hello");
|
|
292
|
+
scope.$digest();
|
|
264
293
|
expect(element.html()).toEqual("hello");
|
|
265
294
|
scope.html = $sce.trustAsHtml("goodbye");
|
|
295
|
+
scope.$digest();
|
|
266
296
|
expect(element.html()).toEqual("goodbye");
|
|
267
297
|
});
|
|
268
298
|
|
|
@@ -274,6 +304,7 @@ describe("ng-bind", () => {
|
|
|
274
304
|
$rootScope.getHtml = function () {
|
|
275
305
|
return $sce.trustAsHtml('<div onclick="">hello</div>');
|
|
276
306
|
};
|
|
307
|
+
$rootScope.$digest();
|
|
277
308
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
278
309
|
});
|
|
279
310
|
|
|
@@ -330,8 +361,10 @@ describe("ng-bind", () => {
|
|
|
330
361
|
$rootScope.getHtml = function () {
|
|
331
362
|
return $sce.trustAsHtml(html);
|
|
332
363
|
};
|
|
364
|
+
$rootScope.$digest();
|
|
333
365
|
expect(element.html()).toEqual("hello");
|
|
334
366
|
html = "goodbye";
|
|
367
|
+
$rootScope.$digest();
|
|
335
368
|
expect(element.html()).toEqual("goodbye");
|
|
336
369
|
};
|
|
337
370
|
});
|
|
@@ -16,6 +16,7 @@ describe("ngBindHtml", () => {
|
|
|
16
16
|
it("should set html", () => {
|
|
17
17
|
const element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
18
18
|
$rootScope.html = "<div>hello</div>";
|
|
19
|
+
$rootScope.$digest();
|
|
19
20
|
expect(element.html()).toEqual("<div>hello</div>");
|
|
20
21
|
});
|
|
21
22
|
|
|
@@ -24,9 +25,11 @@ describe("ngBindHtml", () => {
|
|
|
24
25
|
|
|
25
26
|
[null, undefined, ""].forEach((val) => {
|
|
26
27
|
$rootScope.html = "some val";
|
|
28
|
+
$rootScope.$digest();
|
|
27
29
|
expect(element.html()).toEqual("some val");
|
|
28
30
|
|
|
29
31
|
$rootScope.html = val;
|
|
32
|
+
$rootScope.$digest();
|
|
30
33
|
expect(element.html()).toEqual("");
|
|
31
34
|
});
|
|
32
35
|
});
|
|
@@ -47,7 +47,7 @@ function classDirective(name, selector) {
|
|
|
47
47
|
if (hasAnimate(element[0])) {
|
|
48
48
|
attr.$addClass(classString);
|
|
49
49
|
} else {
|
|
50
|
-
scope
|
|
50
|
+
scope.$$postDigest(() => {
|
|
51
51
|
if (classString !== "") {
|
|
52
52
|
element[0].classList.add(...classString.trim().split(" "));
|
|
53
53
|
}
|
|
@@ -60,7 +60,7 @@ function classDirective(name, selector) {
|
|
|
60
60
|
if (hasAnimate(element[0])) {
|
|
61
61
|
attr.$removeClass(classString);
|
|
62
62
|
} else {
|
|
63
|
-
scope
|
|
63
|
+
scope.$$postDigest(() => {
|
|
64
64
|
if (classString !== "") {
|
|
65
65
|
element[0].classList.remove(...classString.trim().split(" "));
|
|
66
66
|
}
|
|
@@ -82,7 +82,7 @@ function classDirective(name, selector) {
|
|
|
82
82
|
attr.$addClass(toAddString);
|
|
83
83
|
attr.$removeClass(toRemoveString);
|
|
84
84
|
} else {
|
|
85
|
-
scope
|
|
85
|
+
scope.$$postDigest(() => {
|
|
86
86
|
if (toAddString !== "") {
|
|
87
87
|
element[0].classList.add(...toAddString.trim().split(" "));
|
|
88
88
|
}
|
|
@@ -27,15 +27,18 @@ describe("ngClass", () => {
|
|
|
27
27
|
$rootScope,
|
|
28
28
|
);
|
|
29
29
|
$rootScope.dynClass = "A";
|
|
30
|
+
$rootScope.$digest();
|
|
30
31
|
expect(element[0].classList.contains("existing")).toBe(true);
|
|
31
32
|
expect(element[0].classList.contains("A")).toBe(true);
|
|
32
33
|
|
|
33
34
|
$rootScope.dynClass = "B";
|
|
35
|
+
$rootScope.$digest();
|
|
34
36
|
expect(element[0].classList.contains("existing")).toBe(true);
|
|
35
37
|
expect(element[0].classList.contains("A")).toBe(false);
|
|
36
38
|
expect(element[0].classList.contains("B")).toBe(true);
|
|
37
39
|
|
|
38
40
|
delete $rootScope.dynClass;
|
|
41
|
+
$rootScope.$digest();
|
|
39
42
|
expect(element[0].classList.contains("existing")).toBe(true);
|
|
40
43
|
expect(element[0].classList.contains("A")).toBe(false);
|
|
41
44
|
expect(element[0].classList.contains("B")).toBe(false);
|
|
@@ -50,18 +53,21 @@ describe("ngClass", () => {
|
|
|
50
53
|
hasOwnProperty: true,
|
|
51
54
|
isPrototypeOf: true,
|
|
52
55
|
};
|
|
56
|
+
$rootScope.$digest();
|
|
53
57
|
expect(element[0].classList.contains("existing")).toBe(true);
|
|
54
58
|
expect(element[0].classList.contains("watch")).toBe(true);
|
|
55
59
|
expect(element[0].classList.contains("hasOwnProperty")).toBe(true);
|
|
56
60
|
expect(element[0].classList.contains("isPrototypeOf")).toBe(true);
|
|
57
61
|
|
|
58
62
|
$rootScope.dynClass.watch = false;
|
|
63
|
+
$rootScope.$digest();
|
|
59
64
|
expect(element[0].classList.contains("existing")).toBe(true);
|
|
60
65
|
expect(element[0].classList.contains("watch")).toBe(false);
|
|
61
66
|
expect(element[0].classList.contains("hasOwnProperty")).toBe(true);
|
|
62
67
|
expect(element[0].classList.contains("isPrototypeOf")).toBe(true);
|
|
63
68
|
|
|
64
69
|
delete $rootScope.dynClass;
|
|
70
|
+
$rootScope.$digest();
|
|
65
71
|
expect(element[0].classList.contains("existing")).toBe(true);
|
|
66
72
|
expect(element[0].classList.contains("watch")).toBe(false);
|
|
67
73
|
expect(element[0].classList.contains("hasOwnProperty")).toBe(false);
|
|
@@ -72,6 +78,7 @@ describe("ngClass", () => {
|
|
|
72
78
|
element = $compile(
|
|
73
79
|
"<div class=\"existing\" ng-class=\"['A', 'B']\"></div>",
|
|
74
80
|
)($rootScope);
|
|
81
|
+
$rootScope.$digest();
|
|
75
82
|
expect(element[0].classList.contains("existing")).toBeTruthy();
|
|
76
83
|
expect(element[0].classList.contains("A")).toBeTruthy();
|
|
77
84
|
expect(element[0].classList.contains("B")).toBeTruthy();
|
|
@@ -87,6 +94,7 @@ describe("ngClass", () => {
|
|
|
87
94
|
"</div>",
|
|
88
95
|
)($rootScope);
|
|
89
96
|
$rootScope.conditionA = true;
|
|
97
|
+
$rootScope.$digest();
|
|
90
98
|
expect(element[0].classList.contains("existing")).toBeTruthy();
|
|
91
99
|
expect(element[0].classList.contains("A")).toBeTruthy();
|
|
92
100
|
expect(element[0].classList.contains("B")).toBeFalsy();
|
|
@@ -95,6 +103,7 @@ describe("ngClass", () => {
|
|
|
95
103
|
$rootScope.conditionB = function () {
|
|
96
104
|
return true;
|
|
97
105
|
};
|
|
106
|
+
$rootScope.$digest();
|
|
98
107
|
expect(element[0].classList.contains("existing")).toBeTruthy();
|
|
99
108
|
expect(element[0].classList.contains("A")).toBeTruthy();
|
|
100
109
|
expect(element[0].classList.contains("B")).toBeTruthy();
|
|
@@ -104,6 +113,7 @@ describe("ngClass", () => {
|
|
|
104
113
|
|
|
105
114
|
it("should not break when passed non-string/array/object, truthy values", () => {
|
|
106
115
|
element = $compile('<div ng-class="42"></div>')($rootScope);
|
|
116
|
+
$rootScope.$digest();
|
|
107
117
|
expect(element[0].classList.contains("42")).toBeTruthy();
|
|
108
118
|
});
|
|
109
119
|
|
|
@@ -111,19 +121,23 @@ describe("ngClass", () => {
|
|
|
111
121
|
element = $compile(
|
|
112
122
|
"<div class=\"existing\" ng-class=\"['A', {'B': condition}]\"></div>",
|
|
113
123
|
)($rootScope);
|
|
124
|
+
$rootScope.$digest();
|
|
114
125
|
expect(element[0].classList.contains("existing")).toBeTruthy();
|
|
115
126
|
expect(element[0].classList.contains("A")).toBeTruthy();
|
|
116
127
|
expect(element[0].classList.contains("B")).toBeFalsy();
|
|
117
128
|
$rootScope.condition = true;
|
|
129
|
+
$rootScope.$digest();
|
|
118
130
|
expect(element[0].classList.contains("B")).toBeTruthy();
|
|
119
131
|
});
|
|
120
132
|
|
|
121
133
|
it("should remove classes when the referenced object is the same but its property is changed", () => {
|
|
122
134
|
element = $compile('<div ng-class="classes"></div>')($rootScope);
|
|
123
135
|
$rootScope.classes = { A: true, B: true };
|
|
136
|
+
$rootScope.$digest();
|
|
124
137
|
expect(element[0].classList.contains("A")).toBeTruthy();
|
|
125
138
|
expect(element[0].classList.contains("B")).toBeTruthy();
|
|
126
139
|
$rootScope.classes.A = false;
|
|
140
|
+
$rootScope.$digest();
|
|
127
141
|
expect(element[0].classList.contains("A")).toBeFalsy();
|
|
128
142
|
expect(element[0].classList.contains("B")).toBeTruthy();
|
|
129
143
|
});
|
|
@@ -132,6 +146,7 @@ describe("ngClass", () => {
|
|
|
132
146
|
element = $compile('<div class="existing" ng-class="\'A B\'"></div>')(
|
|
133
147
|
$rootScope,
|
|
134
148
|
);
|
|
149
|
+
$rootScope.$digest();
|
|
135
150
|
expect(element[0].classList.contains("existing")).toBeTruthy();
|
|
136
151
|
expect(element[0].classList.contains("A")).toBeTruthy();
|
|
137
152
|
expect(element[0].classList.contains("B")).toBeTruthy();
|
|
@@ -141,6 +156,7 @@ describe("ngClass", () => {
|
|
|
141
156
|
element = $compile(
|
|
142
157
|
"<div class=\"existing\" ng-class=\"['A B', 'C']\"></div>",
|
|
143
158
|
)($rootScope);
|
|
159
|
+
$rootScope.$digest();
|
|
144
160
|
expect(element[0].classList.contains("existing")).toBeTruthy();
|
|
145
161
|
expect(element[0].classList.contains("A")).toBeTruthy();
|
|
146
162
|
expect(element[0].classList.contains("B")).toBeTruthy();
|
|
@@ -152,11 +168,14 @@ describe("ngClass", () => {
|
|
|
152
168
|
$rootScope,
|
|
153
169
|
);
|
|
154
170
|
$rootScope.dynClass = "A";
|
|
171
|
+
$rootScope.$digest();
|
|
155
172
|
expect(element[0].classList.contains("existing")).toBe(true);
|
|
156
173
|
|
|
157
174
|
// add extra class, change model and eval
|
|
158
175
|
element[0].classList.add("newClass");
|
|
159
176
|
$rootScope.dynClass = "B";
|
|
177
|
+
$rootScope.$digest();
|
|
178
|
+
|
|
160
179
|
expect(element[0].classList.contains("existing")).toBe(true);
|
|
161
180
|
expect(element[0].classList.contains("B")).toBe(true);
|
|
162
181
|
expect(element[0].classList.contains("newClass")).toBe(true);
|
|
@@ -165,11 +184,14 @@ describe("ngClass", () => {
|
|
|
165
184
|
it('should preserve class added post compilation without pre-existing classes"', () => {
|
|
166
185
|
element = $compile('<div ng-class="dynClass"></div>')($rootScope);
|
|
167
186
|
$rootScope.dynClass = "A";
|
|
187
|
+
$rootScope.$digest();
|
|
168
188
|
expect(element[0].classList.contains("A")).toBe(true);
|
|
169
189
|
|
|
170
190
|
// add extra class, change model and eval
|
|
171
191
|
element[0].classList.add("newClass");
|
|
172
192
|
$rootScope.dynClass = "B";
|
|
193
|
+
$rootScope.$digest();
|
|
194
|
+
|
|
173
195
|
expect(element[0].classList.contains("B")).toBe(true);
|
|
174
196
|
expect(element[0].classList.contains("newClass")).toBe(true);
|
|
175
197
|
});
|
|
@@ -179,7 +201,9 @@ describe("ngClass", () => {
|
|
|
179
201
|
'<div class="ui-panel ui-selected" ng-class="dynCls"></div>',
|
|
180
202
|
)($rootScope);
|
|
181
203
|
$rootScope.dynCls = "panel";
|
|
204
|
+
$rootScope.$digest();
|
|
182
205
|
$rootScope.dynCls = "foo";
|
|
206
|
+
$rootScope.$digest();
|
|
183
207
|
expect(element[0].className).toBe("ui-panel ui-selected foo");
|
|
184
208
|
});
|
|
185
209
|
|
|
@@ -188,6 +212,7 @@ describe("ngClass", () => {
|
|
|
188
212
|
$rootScope,
|
|
189
213
|
);
|
|
190
214
|
$rootScope.dynCls = "panel";
|
|
215
|
+
$rootScope.$digest();
|
|
191
216
|
expect(element[0].className).toBe("panel bar");
|
|
192
217
|
});
|
|
193
218
|
|
|
@@ -196,26 +221,32 @@ describe("ngClass", () => {
|
|
|
196
221
|
$rootScope,
|
|
197
222
|
);
|
|
198
223
|
$rootScope.dynCls = "panel";
|
|
224
|
+
$rootScope.$digest();
|
|
199
225
|
$rootScope.dynCls = "window";
|
|
226
|
+
$rootScope.$digest();
|
|
200
227
|
expect(element[0].className).toBe("bar window");
|
|
201
228
|
});
|
|
202
229
|
|
|
203
230
|
it("should remove classes even if they were added by another code", () => {
|
|
204
231
|
element = $compile('<div ng-class="dynCls"></div>')($rootScope);
|
|
205
232
|
$rootScope.dynCls = "foo";
|
|
233
|
+
$rootScope.$digest();
|
|
206
234
|
element[0].classList.add("foo");
|
|
207
235
|
$rootScope.dynCls = "";
|
|
236
|
+
$rootScope.$digest();
|
|
208
237
|
});
|
|
209
238
|
|
|
210
239
|
it("should convert undefined and null values to an empty string", () => {
|
|
211
240
|
element = $compile('<div ng-class="dynCls"></div>')($rootScope);
|
|
212
241
|
$rootScope.dynCls = [undefined, null];
|
|
242
|
+
$rootScope.$digest();
|
|
213
243
|
});
|
|
214
244
|
|
|
215
245
|
it("should ngClass odd/even", () => {
|
|
216
246
|
element = $compile(
|
|
217
247
|
'<ul><li ng-repeat="i in [0,1]" class="existing" ng-class-odd="\'odd\'" ng-class-even="\'even\'"></li><ul>',
|
|
218
248
|
)($rootScope);
|
|
249
|
+
$rootScope.$digest();
|
|
219
250
|
const e1 = JQLite(element[0].childNodes[1]);
|
|
220
251
|
const e2 = JQLite(element[0].childNodes[3]);
|
|
221
252
|
expect(e1[0].classList.contains("existing")).toBeTruthy();
|
|
@@ -252,6 +283,8 @@ describe("ngClass", () => {
|
|
|
252
283
|
"</li>" +
|
|
253
284
|
"<ul>",
|
|
254
285
|
)($rootScope);
|
|
286
|
+
$rootScope.$digest();
|
|
287
|
+
|
|
255
288
|
const e1 = element.children().eq(0)[0];
|
|
256
289
|
const e2 = element.children().eq(1)[0];
|
|
257
290
|
const e3 = element.children().eq(2)[0];
|
|
@@ -271,6 +304,8 @@ describe("ngClass", () => {
|
|
|
271
304
|
element = $compile(
|
|
272
305
|
"<div ng-class=\"{'same yes': test, 'same no': !test}\"></div>",
|
|
273
306
|
)($rootScope)[0];
|
|
307
|
+
$rootScope.$digest();
|
|
308
|
+
|
|
274
309
|
expect(element).toHaveClass("same");
|
|
275
310
|
expect(element).not.toHaveClass("yes");
|
|
276
311
|
expect(element).toHaveClass("no");
|
|
@@ -387,6 +422,7 @@ describe("ngClass", () => {
|
|
|
387
422
|
$rootScope.foo = false;
|
|
388
423
|
});
|
|
389
424
|
element = $compile('<div ng-class="{foo:foo}"></div>')($rootScope);
|
|
425
|
+
$rootScope.$digest();
|
|
390
426
|
expect(element[0].classList.contains("foo")).toBe(false);
|
|
391
427
|
});
|
|
392
428
|
|
|
@@ -398,7 +434,11 @@ describe("ngClass", () => {
|
|
|
398
434
|
"<ul>",
|
|
399
435
|
)($rootScope);
|
|
400
436
|
$rootScope.items = ["b", "c", "d"];
|
|
437
|
+
$rootScope.$digest();
|
|
438
|
+
|
|
401
439
|
$rootScope.items.unshift("a");
|
|
440
|
+
$rootScope.$digest();
|
|
441
|
+
|
|
402
442
|
const e1 = JQLite(element[0].childNodes[1]);
|
|
403
443
|
const e4 = JQLite(element[0].childNodes[3]);
|
|
404
444
|
|
|
@@ -417,7 +457,11 @@ describe("ngClass", () => {
|
|
|
417
457
|
"<ul>",
|
|
418
458
|
)($rootScope);
|
|
419
459
|
$rootScope.items = ["a", "b", "a"];
|
|
460
|
+
$rootScope.$digest();
|
|
461
|
+
|
|
420
462
|
$rootScope.items = ["a", "a"];
|
|
463
|
+
$rootScope.$digest();
|
|
464
|
+
|
|
421
465
|
const e1 = JQLite(element[0].childNodes[1]);
|
|
422
466
|
const e2 = JQLite(element[0].childNodes[3]);
|
|
423
467
|
|
|
@@ -436,7 +480,11 @@ describe("ngClass", () => {
|
|
|
436
480
|
"<ul>",
|
|
437
481
|
)($rootScope);
|
|
438
482
|
$rootScope.items = ["a", "b"];
|
|
483
|
+
$rootScope.$digest();
|
|
484
|
+
|
|
439
485
|
$rootScope.items = ["b", "a"];
|
|
486
|
+
$rootScope.$digest();
|
|
487
|
+
|
|
440
488
|
const e1 = JQLite(element[0].childNodes[1]);
|
|
441
489
|
const e2 = JQLite(element[0].childNodes[3]);
|
|
442
490
|
|
|
@@ -490,9 +538,12 @@ describe("ngClass", () => {
|
|
|
490
538
|
element = $compile('<div ng-class="classVar"></div>')($rootScope);
|
|
491
539
|
|
|
492
540
|
$rootScope.classVar = [{ orange: true }];
|
|
541
|
+
$rootScope.$digest();
|
|
493
542
|
expect(element[0]).toHaveClass("orange");
|
|
494
543
|
|
|
495
544
|
$rootScope.classVar[0].orange = false;
|
|
545
|
+
$rootScope.$digest();
|
|
546
|
+
|
|
496
547
|
expect(element[0]).not.toHaveClass("orange");
|
|
497
548
|
});
|
|
498
549
|
|
|
@@ -501,9 +552,12 @@ describe("ngClass", () => {
|
|
|
501
552
|
element = $compile('<div ng-class="[classVar]"></div>')($rootScope);
|
|
502
553
|
|
|
503
554
|
$rootScope.classVar = { orange: true };
|
|
555
|
+
$rootScope.$digest();
|
|
504
556
|
expect(element[0]).toHaveClass("orange");
|
|
505
557
|
|
|
506
558
|
$rootScope.classVar.orange = false;
|
|
559
|
+
$rootScope.$digest();
|
|
560
|
+
|
|
507
561
|
expect(element[0]).not.toHaveClass("orange");
|
|
508
562
|
});
|
|
509
563
|
|
|
@@ -513,9 +567,12 @@ describe("ngClass", () => {
|
|
|
513
567
|
);
|
|
514
568
|
|
|
515
569
|
$rootScope.classVar1 = { orange: true };
|
|
570
|
+
$rootScope.$digest();
|
|
516
571
|
expect(element[0]).toHaveClass("orange");
|
|
517
572
|
|
|
518
573
|
$rootScope.classVar1.orange = false;
|
|
574
|
+
$rootScope.$digest();
|
|
575
|
+
|
|
519
576
|
expect(element[0]).not.toHaveClass("orange");
|
|
520
577
|
});
|
|
521
578
|
|
|
@@ -556,6 +613,7 @@ describe("ngClass", () => {
|
|
|
556
613
|
$rootScope.classVar = [{ orange: true }];
|
|
557
614
|
element = $compile('<div ng-class="classVar"></div>')($rootScope);
|
|
558
615
|
|
|
616
|
+
$rootScope.$digest();
|
|
559
617
|
expect(element[0]).toHaveClass("orange");
|
|
560
618
|
|
|
561
619
|
$rootScope.$apply("classVar[0].orange = false");
|
|
@@ -606,6 +664,8 @@ describe("ngClass", () => {
|
|
|
606
664
|
it("should not be copied when using an expression", () => {
|
|
607
665
|
element = $compile('<div ng-class="fooClass"></div>')($rootScope)[0];
|
|
608
666
|
$rootScope.fooClass = { foo: veryLargeObj };
|
|
667
|
+
$rootScope.$digest();
|
|
668
|
+
|
|
609
669
|
expect(element).toHaveClass("foo");
|
|
610
670
|
expect(getProp).not.toHaveBeenCalled();
|
|
611
671
|
});
|
|
@@ -615,6 +675,8 @@ describe("ngClass", () => {
|
|
|
615
675
|
$rootScope,
|
|
616
676
|
)[0];
|
|
617
677
|
$rootScope.veryLargeObj = veryLargeObj;
|
|
678
|
+
$rootScope.$digest();
|
|
679
|
+
|
|
618
680
|
expect(element).toHaveClass("foo");
|
|
619
681
|
expect(getProp).not.toHaveBeenCalled();
|
|
620
682
|
});
|
|
@@ -624,6 +686,8 @@ describe("ngClass", () => {
|
|
|
624
686
|
$rootScope,
|
|
625
687
|
)[0];
|
|
626
688
|
$rootScope.veryLargeObj = veryLargeObj;
|
|
689
|
+
$rootScope.$digest();
|
|
690
|
+
|
|
627
691
|
expect(element).toHaveClass("foo");
|
|
628
692
|
expect(getProp).not.toHaveBeenCalled();
|
|
629
693
|
});
|
|
@@ -633,6 +697,8 @@ describe("ngClass", () => {
|
|
|
633
697
|
'<div ng-class="::{foo: veryLargeObj, bar: bar}"></div>',
|
|
634
698
|
)($rootScope)[0];
|
|
635
699
|
$rootScope.veryLargeObj = veryLargeObj;
|
|
700
|
+
$rootScope.$digest();
|
|
701
|
+
|
|
636
702
|
expect(element).toHaveClass("foo");
|
|
637
703
|
expect(element).not.toHaveClass("bar");
|
|
638
704
|
expect(getProp).not.toHaveBeenCalled();
|
|
@@ -678,22 +744,22 @@ describe("ngClass", () => {
|
|
|
678
744
|
// expect($animate.queue.length).toBe(0);
|
|
679
745
|
|
|
680
746
|
// $rootScope.val = "one";
|
|
681
|
-
// ;
|
|
747
|
+
// $rootScope.$digest();
|
|
682
748
|
// expect($animate.queue.shift().event).toBe("addClass");
|
|
683
749
|
// expect($animate.queue.length).toBe(0);
|
|
684
750
|
|
|
685
751
|
// $rootScope.val = "";
|
|
686
|
-
// ;
|
|
752
|
+
// $rootScope.$digest();
|
|
687
753
|
// expect($animate.queue.shift().event).toBe("removeClass"); // only removeClass is called
|
|
688
754
|
// expect($animate.queue.length).toBe(0);
|
|
689
755
|
|
|
690
756
|
// $rootScope.val = "one";
|
|
691
|
-
// ;
|
|
757
|
+
// $rootScope.$digest();
|
|
692
758
|
// expect($animate.queue.shift().event).toBe("addClass");
|
|
693
759
|
// expect($animate.queue.length).toBe(0);
|
|
694
760
|
|
|
695
761
|
// $rootScope.val = "two";
|
|
696
|
-
// ;
|
|
762
|
+
// $rootScope.$digest();
|
|
697
763
|
// expect($animate.queue.shift().event).toBe("addClass");
|
|
698
764
|
// expect($animate.queue.shift().event).toBe("removeClass");
|
|
699
765
|
// expect($animate.queue.length).toBe(0);
|
|
@@ -734,9 +800,9 @@ describe("ngClass", () => {
|
|
|
734
800
|
// expect(element[0].classList.contains("crazy")).toBe(false);
|
|
735
801
|
// expect(enterComplete).toBe(false);
|
|
736
802
|
|
|
737
|
-
// ;
|
|
803
|
+
// $rootScope.$digest();
|
|
738
804
|
// $animate.flush();
|
|
739
|
-
// ;
|
|
805
|
+
// $rootScope.$digest();
|
|
740
806
|
|
|
741
807
|
// expect(element[0].classList.contains("crazy")).toBe(true);
|
|
742
808
|
// expect(enterComplete).toBe(true);
|
|
@@ -759,7 +825,7 @@ describe("ngClass", () => {
|
|
|
759
825
|
// '<div ng-class="{one:one, two:two, three:three}"></div>',
|
|
760
826
|
// );
|
|
761
827
|
// $compile(element)($rootScope);
|
|
762
|
-
// ;
|
|
828
|
+
// $rootScope.$digest();
|
|
763
829
|
|
|
764
830
|
// // this fires twice due to the class observer firing
|
|
765
831
|
// let item = $animate.queue.shift();
|
|
@@ -769,7 +835,7 @@ describe("ngClass", () => {
|
|
|
769
835
|
// expect($animate.queue.length).toBe(0);
|
|
770
836
|
|
|
771
837
|
// $rootScope.three = false;
|
|
772
|
-
// ;
|
|
838
|
+
// $rootScope.$digest();
|
|
773
839
|
|
|
774
840
|
// item = $animate.queue.shift();
|
|
775
841
|
// expect(item.event).toBe("removeClass");
|
|
@@ -779,7 +845,7 @@ describe("ngClass", () => {
|
|
|
779
845
|
|
|
780
846
|
// $rootScope.two = false;
|
|
781
847
|
// $rootScope.three = true;
|
|
782
|
-
// ;
|
|
848
|
+
// $rootScope.$digest();
|
|
783
849
|
|
|
784
850
|
// item = $animate.queue.shift();
|
|
785
851
|
// expect(item.event).toBe("addClass");
|