@angular-wave/angular.ts 0.0.52 → 0.0.54
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 -2
- package/package.json +1 -1
- package/src/angular.spec.js +0 -8
- package/src/animations/animate-css-driver.js +2 -3
- package/src/animations/animate-queue.js +1 -3
- package/src/animations/animate.md +933 -0
- package/src/animations/module.js +0 -754
- package/src/binding.spec.js +0 -2
- package/src/core/animate/animate-css.js +21 -6
- package/src/core/animate/animate.js +4 -3
- package/src/core/animate/animate.spec.js +194 -286
- package/src/core/animate/helpers.js +10 -0
- package/src/core/compile/compile.spec.js +3 -5
- package/src/core/location/location.spec.js +7 -7
- package/src/core/url-utils/url-utils.spec.js +1 -3
- package/src/directive/options/options.js +2 -3
- package/src/directive/repeat/repeat.spec.js +1 -1
- package/src/exts/messages/messages.js +1 -2
- package/src/public.js +0 -7
- package/src/services/cookie-reader.js +2 -6
- package/src/services/http-backend/http-backend.js +0 -1
- package/types/animations/animate-css-driver.d.ts +1 -1
- package/types/animations/animate-queue.d.ts +1 -1
- package/types/animations/module.d.ts +0 -749
- package/types/core/animate/animate-css.d.ts +1 -1
- package/types/core/animate/helpers.d.ts +8 -0
- package/types/directive/options/options.d.ts +1 -1
- package/types/services/cookie-reader.d.ts +1 -6
- package/types/services/http-backend/http-backend.d.ts +0 -1
- package/src/services/document.js +0 -67
- package/types/services/document.d.ts +0 -41
|
@@ -1,17 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
|
|
2
|
+
import { publishExternalAPI } from "../../public";
|
|
3
|
+
import { Angular } from "../../loader";
|
|
4
|
+
import { isObject } from "../../shared/utils";
|
|
5
|
+
import { isFunction } from "../../shared/utils";
|
|
6
|
+
import { createInjector } from "../../injector";
|
|
7
|
+
|
|
8
|
+
describe("$animate", () => {
|
|
2
9
|
describe("without animation", () => {
|
|
10
|
+
let dummy = window.document.getElementById("dummy");
|
|
3
11
|
let element;
|
|
12
|
+
let $compile;
|
|
4
13
|
let $rootElement;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
14
|
-
|
|
14
|
+
let $rootScope;
|
|
15
|
+
let defaultModule;
|
|
16
|
+
let injector;
|
|
17
|
+
let $animate;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
window.angular = new Angular();
|
|
21
|
+
publishExternalAPI();
|
|
22
|
+
defaultModule = window.angular.module("defaultModule", ["ng"]);
|
|
23
|
+
injector = window.angular.bootstrap(dummy, ["defaultModule"]);
|
|
24
|
+
injector.invoke(
|
|
25
|
+
(_$compile_, _$rootElement_, _$rootScope_, _$animate_) => {
|
|
26
|
+
$compile = _$compile_;
|
|
27
|
+
$rootScope = _$rootScope_;
|
|
28
|
+
element = $compile("<div></div>")($rootScope);
|
|
29
|
+
$rootElement = _$rootElement_;
|
|
30
|
+
$animate = _$animate_;
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
});
|
|
15
34
|
|
|
16
35
|
it("should add element at the start of enter animation", () => {
|
|
17
36
|
const child = $compile("<div></div>")($rootScope);
|
|
@@ -51,36 +70,36 @@ xdescribe("$animate", () => {
|
|
|
51
70
|
|
|
52
71
|
it("should apply styles instantly to the element", () => {
|
|
53
72
|
$animate.animate(element, { color: "rgb(0, 0, 0)" });
|
|
54
|
-
expect(element[0].
|
|
73
|
+
expect(element[0].style.color).toBe("rgb(0, 0, 0)");
|
|
55
74
|
|
|
56
75
|
$animate.animate(
|
|
57
76
|
element,
|
|
58
77
|
{ color: "rgb(255, 0, 0)" },
|
|
59
78
|
{ color: "rgb(0, 255, 0)" },
|
|
60
79
|
);
|
|
61
|
-
expect(element[0].
|
|
80
|
+
expect(element[0].style.color).toBe("rgb(0, 255, 0)");
|
|
62
81
|
});
|
|
63
82
|
|
|
64
83
|
it("should still perform DOM operations even if animations are disabled (post-digest)", () => {
|
|
65
84
|
$animate.enabled(false);
|
|
66
|
-
expect(element).
|
|
85
|
+
expect(element[0].classList.contains("ng-hide")).toBeFalse();
|
|
67
86
|
$animate.addClass(element, "ng-hide");
|
|
68
87
|
$rootScope.$digest();
|
|
69
|
-
expect(element).
|
|
88
|
+
expect(element[0].classList.contains("ng-hide")).toBeTrue();
|
|
70
89
|
});
|
|
71
90
|
|
|
72
91
|
it("should run each method and return a promise", () => {
|
|
73
92
|
const element = JQLite("<div></div>");
|
|
74
93
|
const move = JQLite("<div></div>");
|
|
75
|
-
const parent = JQLite(
|
|
94
|
+
const parent = JQLite(document.body);
|
|
76
95
|
parent.append(move);
|
|
77
96
|
|
|
78
|
-
expect($animate.enter(element, parent)).
|
|
79
|
-
expect($animate.move(element, move)).
|
|
80
|
-
expect($animate.addClass(element, "on")).
|
|
81
|
-
expect($animate.removeClass(element, "off")).
|
|
82
|
-
expect($animate.setClass(element, "on", "off")).
|
|
83
|
-
expect($animate.leave(element)).
|
|
97
|
+
expect($animate.enter(element, parent).then).toBeDefined();
|
|
98
|
+
expect($animate.move(element, move).then).toBeDefined();
|
|
99
|
+
expect($animate.addClass(element, "on").then).toBeDefined();
|
|
100
|
+
expect($animate.removeClass(element, "off").then).toBeDefined();
|
|
101
|
+
expect($animate.setClass(element, "on", "off").then).toBeDefined();
|
|
102
|
+
expect($animate.leave(element).then).toBeDefined();
|
|
84
103
|
});
|
|
85
104
|
|
|
86
105
|
it("should provide the `enabled` and `cancel` methods", () => {
|
|
@@ -98,42 +117,40 @@ xdescribe("$animate", () => {
|
|
|
98
117
|
const svg = JQLite("<svg><rect></rect></svg>");
|
|
99
118
|
const rect = svg.children();
|
|
100
119
|
$animate.enabled(false);
|
|
101
|
-
expect(rect).
|
|
120
|
+
expect(rect[0].classList.contains("ng-hide")).toBeFalse();
|
|
102
121
|
$animate.addClass(rect, "ng-hide");
|
|
103
122
|
$rootScope.$digest();
|
|
104
|
-
expect(rect).
|
|
123
|
+
expect(rect[0].classList.contains("ng-hide")).toBeTrue();
|
|
105
124
|
$animate.removeClass(rect, "ng-hide");
|
|
106
125
|
$rootScope.$digest();
|
|
107
|
-
expect(rect
|
|
126
|
+
expect(rect[0].classList.contains("ng-hide")).toBeFalse();
|
|
108
127
|
});
|
|
109
128
|
|
|
110
129
|
it("should throw error on wrong selector", () => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
130
|
+
createInjector([
|
|
131
|
+
"ng",
|
|
132
|
+
($animateProvider) => {
|
|
133
|
+
expect(() => {
|
|
134
|
+
$animateProvider.register("abc", null);
|
|
135
|
+
}).toThrowError(/notcsel/);
|
|
136
|
+
},
|
|
137
|
+
]);
|
|
120
138
|
});
|
|
121
139
|
|
|
122
140
|
it("should register the animation and be available for lookup", () => {
|
|
123
141
|
let provider;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
};
|
|
142
|
+
createInjector([
|
|
143
|
+
"ng",
|
|
144
|
+
($animateProvider) => {
|
|
145
|
+
provider = $animateProvider;
|
|
146
|
+
},
|
|
147
|
+
]);
|
|
148
|
+
// by using hasOwnProperty we know for sure that the lookup object is an empty object
|
|
149
|
+
// instead of inheriting properties from its original prototype.
|
|
150
|
+
expect(provider.$$registeredAnimations.hasOwnProperty).toBeFalsy();
|
|
151
|
+
|
|
152
|
+
provider.register(".filter", () => {});
|
|
153
|
+
expect(provider.$$registeredAnimations.filter).toBe(".filter-animation");
|
|
137
154
|
});
|
|
138
155
|
|
|
139
156
|
it("should apply and retain inline styles on the element that is animated", () => {
|
|
@@ -204,7 +221,7 @@ xdescribe("$animate", () => {
|
|
|
204
221
|
$animate.removeClass(element, "ng-hide");
|
|
205
222
|
$rootScope.$digest();
|
|
206
223
|
|
|
207
|
-
expect(element
|
|
224
|
+
expect(element[0].classList.contains("ng-hide")).toBeFalse();
|
|
208
225
|
});
|
|
209
226
|
|
|
210
227
|
it("should avoid cancelling out remove/add if the element does not contain the class", () => {
|
|
@@ -214,13 +231,13 @@ xdescribe("$animate", () => {
|
|
|
214
231
|
$animate.addClass(element, "ng-hide");
|
|
215
232
|
$rootScope.$digest();
|
|
216
233
|
|
|
217
|
-
expect(element
|
|
234
|
+
expect(element[0].classList.contains("ng-hide")).toBeTrue();
|
|
218
235
|
});
|
|
219
236
|
|
|
220
237
|
["enter", "move"].forEach((method) => {
|
|
221
238
|
it('should accept an unwrapped "parent" element for the $prop event', () => {
|
|
222
239
|
const element = JQLite("<div></div>");
|
|
223
|
-
const parent =
|
|
240
|
+
const parent = document.createElement("div");
|
|
224
241
|
$rootElement.append(parent);
|
|
225
242
|
|
|
226
243
|
$animate[method](element, parent);
|
|
@@ -231,7 +248,7 @@ xdescribe("$animate", () => {
|
|
|
231
248
|
["enter", "move"].forEach((method) => {
|
|
232
249
|
it('should accept an unwrapped "after" element for the $prop event', () => {
|
|
233
250
|
const element = JQLite("<div></div>");
|
|
234
|
-
const after =
|
|
251
|
+
const after = document.createElement("div");
|
|
235
252
|
$rootElement.append(after);
|
|
236
253
|
|
|
237
254
|
$animate[method](element, null, after);
|
|
@@ -250,14 +267,24 @@ xdescribe("$animate", () => {
|
|
|
250
267
|
].forEach((event) => {
|
|
251
268
|
it("$prop() should operate using a native DOM element", () => {
|
|
252
269
|
const captureSpy = jasmine.createSpy();
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
270
|
+
dealoc(dummy);
|
|
271
|
+
publishExternalAPI();
|
|
272
|
+
defaultModule = window.angular
|
|
273
|
+
.module("defaultModule", ["ng"])
|
|
274
|
+
.value("$$animateQueue", {
|
|
256
275
|
push: captureSpy,
|
|
257
276
|
});
|
|
258
|
-
|
|
277
|
+
injector = window.angular.bootstrap(dummy, ["defaultModule"]);
|
|
278
|
+
injector.invoke(
|
|
279
|
+
(_$compile_, _$rootElement_, _$rootScope_, _$animate_) => {
|
|
280
|
+
$compile = _$compile_;
|
|
281
|
+
$rootScope = _$rootScope_;
|
|
282
|
+
$rootElement = _$rootElement_;
|
|
283
|
+
$animate = _$animate_;
|
|
284
|
+
},
|
|
285
|
+
);
|
|
259
286
|
|
|
260
|
-
|
|
287
|
+
element = JQLite("<div></div>");
|
|
261
288
|
const parent2 = JQLite("<div></div>");
|
|
262
289
|
const parent = $rootElement;
|
|
263
290
|
parent.append(parent2);
|
|
@@ -321,286 +348,167 @@ xdescribe("$animate", () => {
|
|
|
321
348
|
expect(isObject(optionsArg)).toBeTruthy();
|
|
322
349
|
});
|
|
323
350
|
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it("should not issue a call to addClass if the provided class value is not a string or array", () => {
|
|
327
|
-
() => {
|
|
328
|
-
const spy = spyOn(window, "jqLiteAddClass").and.callThrough();
|
|
329
351
|
|
|
330
|
-
|
|
331
|
-
const
|
|
352
|
+
it("should not break postDigest for subsequent elements if addClass contains non-valid CSS class names", () => {
|
|
353
|
+
const element1 = JQLite("<div></div>");
|
|
354
|
+
const element2 = JQLite("<div></div>");
|
|
332
355
|
|
|
333
|
-
$animate.enter(
|
|
356
|
+
$animate.enter(element1, $rootElement, null, { addClass: " " });
|
|
357
|
+
$animate.enter(element2, $rootElement, null, { addClass: "valid-name" });
|
|
334
358
|
$rootScope.$digest();
|
|
335
|
-
expect(spy).not.toHaveBeenCalled();
|
|
336
359
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
expect(spy).not.toHaveBeenCalled();
|
|
340
|
-
|
|
341
|
-
$animate.enter(element, parent, null, { addClass: "fatias" });
|
|
342
|
-
$rootScope.$digest();
|
|
343
|
-
expect(spy).toHaveBeenCalled();
|
|
344
|
-
};
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
it("should not break postDigest for subsequent elements if addClass contains non-valid CSS class names", () => {
|
|
348
|
-
const element1 = JQLite("<div></div>");
|
|
349
|
-
const element2 = JQLite("<div></div>");
|
|
350
|
-
|
|
351
|
-
$animate.enter(element1, $rootElement, null, { addClass: " " });
|
|
352
|
-
$animate.enter(element2, $rootElement, null, { addClass: "valid-name" });
|
|
353
|
-
$rootScope.$digest();
|
|
354
|
-
|
|
355
|
-
expect(
|
|
356
|
-
element2[0].classList.contains(ist.contains("valid-name")),
|
|
357
|
-
).toBeTruthy();
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it("should not issue a call to removeClass if the provided class value is not a string or array", () => {
|
|
361
|
-
() => {
|
|
362
|
-
const spy = spyOn(window, "jqLiteRemoveClass").and.callThrough();
|
|
360
|
+
expect(element2[0].classList.contains("valid-name")).toBeTruthy();
|
|
361
|
+
});
|
|
363
362
|
|
|
363
|
+
it("should not alter the provided options input in any way throughout the animation", () => {
|
|
364
364
|
const element = JQLite("<div></div>");
|
|
365
365
|
const parent = $rootElement;
|
|
366
366
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
367
|
+
const initialOptions = {
|
|
368
|
+
from: { height: "50px" },
|
|
369
|
+
to: { width: "50px" },
|
|
370
|
+
addClass: "one",
|
|
371
|
+
removeClass: "two",
|
|
372
|
+
};
|
|
370
373
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
expect(spy).not.toHaveBeenCalled();
|
|
374
|
+
const copiedOptions = structuredClone(initialOptions);
|
|
375
|
+
expect(copiedOptions).toEqual(initialOptions);
|
|
374
376
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
$rootScope.$digest();
|
|
378
|
-
expect(spy).toHaveBeenCalled();
|
|
379
|
-
};
|
|
380
|
-
});
|
|
377
|
+
const runner = $animate.enter(element, parent, null, copiedOptions);
|
|
378
|
+
expect(copiedOptions).toEqual(initialOptions);
|
|
381
379
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
380
|
+
$rootScope.$digest();
|
|
381
|
+
expect(copiedOptions).toEqual(initialOptions);
|
|
382
|
+
});
|
|
385
383
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
removeClass: "two",
|
|
391
|
-
};
|
|
384
|
+
describe("CSS class DOM manipulation", () => {
|
|
385
|
+
let element;
|
|
386
|
+
let addClass;
|
|
387
|
+
let removeClass;
|
|
392
388
|
|
|
393
|
-
|
|
394
|
-
|
|
389
|
+
afterEach(() => {
|
|
390
|
+
dealoc(element);
|
|
391
|
+
});
|
|
395
392
|
|
|
396
|
-
|
|
397
|
-
|
|
393
|
+
it("should defer class manipulation until end of digest", () => {
|
|
394
|
+
element = JQLite("<p>test</p>");
|
|
398
395
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
396
|
+
$rootScope.$apply(() => {
|
|
397
|
+
$animate.addClass(element, "test-class1");
|
|
398
|
+
expect(element[0].classList.contains("test-class1")).toBeFalse();
|
|
402
399
|
|
|
403
|
-
|
|
404
|
-
let element;
|
|
405
|
-
let addClass;
|
|
406
|
-
let removeClass;
|
|
400
|
+
$animate.removeClass(element, "test-class1");
|
|
407
401
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
});
|
|
402
|
+
$animate.addClass(element, "test-class2");
|
|
403
|
+
expect(element[0].classList.contains("test-class2")).toBeFalse();
|
|
411
404
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function setupClassManipulationLogger(log) {
|
|
420
|
-
() => {
|
|
421
|
-
const _addClass = JQLiteAddClass;
|
|
422
|
-
addClass = spyOn(window, "jqLiteAddClass").and.callFake(
|
|
423
|
-
(element, classes) => {
|
|
424
|
-
let names = classes;
|
|
425
|
-
if (Object.prototype.toString.call(classes) === "[object Array]")
|
|
426
|
-
names = classes.join(" ");
|
|
427
|
-
log(`addClass(${names})`);
|
|
428
|
-
return _addClass(element, classes);
|
|
429
|
-
},
|
|
430
|
-
);
|
|
405
|
+
$animate.setClass(element, "test-class3", "test-class4");
|
|
406
|
+
expect(element[0].classList.contains("test-class3")).toBeFalse();
|
|
407
|
+
expect(element[0].classList.contains("test-class4")).toBeFalse();
|
|
408
|
+
});
|
|
431
409
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
names = classes.join(" ");
|
|
438
|
-
log(`removeClass(${names})`);
|
|
439
|
-
return _removeClass(element, classes);
|
|
440
|
-
},
|
|
441
|
-
);
|
|
442
|
-
};
|
|
443
|
-
}
|
|
410
|
+
expect(element[0].classList.contains("test-class1")).toBeFalse();
|
|
411
|
+
expect(element[0].classList.contains("test-class4")).toBeFalse();
|
|
412
|
+
expect(element[0].classList.contains("test-class2")).toBeTrue();
|
|
413
|
+
expect(element[0].classList.contains("test-class3")).toBeTrue();
|
|
414
|
+
});
|
|
444
415
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
element = JQLite("<p>test</p>");
|
|
416
|
+
it("should defer class manipulation until postDigest when outside of digest", () => {
|
|
417
|
+
element = JQLite('<p class="test-class4">test</p>');
|
|
448
418
|
|
|
449
|
-
$rootScope.$apply(() => {
|
|
450
419
|
$animate.addClass(element, "test-class1");
|
|
451
|
-
expect(element).not.toHaveClass("test-class1");
|
|
452
|
-
|
|
453
420
|
$animate.removeClass(element, "test-class1");
|
|
454
|
-
|
|
455
421
|
$animate.addClass(element, "test-class2");
|
|
456
|
-
expect(element).not.toHaveClass("test-class2");
|
|
457
|
-
|
|
458
422
|
$animate.setClass(element, "test-class3", "test-class4");
|
|
459
|
-
|
|
460
|
-
expect(element
|
|
461
|
-
expect(
|
|
423
|
+
$rootScope.$digest();
|
|
424
|
+
expect(element[0].classList.contains("test-class1")).toBeFalse();
|
|
425
|
+
expect(element[0].classList.contains("test-class2")).toBeTrue();
|
|
426
|
+
expect(element[0].classList.contains("test-class3")).toBeTrue();
|
|
462
427
|
});
|
|
463
428
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
expect(element).toHaveClass("test-class2");
|
|
467
|
-
expect(element).toHaveClass("test-class3");
|
|
468
|
-
expect(log).toEqual(["addClass(test-class2 test-class3)"]);
|
|
469
|
-
expect(addClass).toHaveBeenCalledTimes(1);
|
|
470
|
-
expect(removeClass).not.toHaveBeenCalled();
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
it("should defer class manipulation until postDigest when outside of digest", () => {
|
|
474
|
-
setupClassManipulationLogger(log);
|
|
475
|
-
element = JQLite('<p class="test-class4">test</p>');
|
|
429
|
+
it("should perform class manipulation in expected order at end of digest", () => {
|
|
430
|
+
element = JQLite('<p class="test-class3">test</p>');
|
|
476
431
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
432
|
+
$rootScope.$apply(() => {
|
|
433
|
+
$animate.addClass(element, "test-class1");
|
|
434
|
+
$animate.addClass(element, "test-class2");
|
|
435
|
+
$animate.removeClass(element, "test-class1");
|
|
436
|
+
$animate.removeClass(element, "test-class3");
|
|
437
|
+
$animate.addClass(element, "test-class3");
|
|
438
|
+
});
|
|
439
|
+
expect(element[0].classList.contains("test-class3")).toBeTrue();
|
|
440
|
+
});
|
|
481
441
|
|
|
482
|
-
|
|
483
|
-
|
|
442
|
+
it("should return a promise which is resolved on a different turn", () => {
|
|
443
|
+
element = JQLite('<p class="test2">test</p>');
|
|
484
444
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
"removeClass(test-class4)",
|
|
488
|
-
]);
|
|
489
|
-
expect(element).not.toHaveClass("test-class1");
|
|
490
|
-
expect(element).toHaveClass("test-class2");
|
|
491
|
-
expect(element).toHaveClass("test-class3");
|
|
492
|
-
expect(addClass).toHaveBeenCalledTimes(1);
|
|
493
|
-
expect(removeClass).toHaveBeenCalledTimes(1);
|
|
494
|
-
});
|
|
445
|
+
$animate.addClass(element, "test1");
|
|
446
|
+
$animate.removeClass(element, "test2");
|
|
495
447
|
|
|
496
|
-
|
|
497
|
-
|
|
448
|
+
$rootScope.$digest();
|
|
449
|
+
element = JQLite('<p class="test4">test</p>');
|
|
498
450
|
|
|
499
|
-
|
|
451
|
+
$rootScope.$apply(() => {
|
|
452
|
+
$animate.addClass(element, "test3");
|
|
453
|
+
$animate.removeClass(element, "test4");
|
|
454
|
+
});
|
|
500
455
|
|
|
501
|
-
|
|
502
|
-
$animate.addClass(element, "test-class1");
|
|
503
|
-
$animate.addClass(element, "test-class2");
|
|
504
|
-
$animate.removeClass(element, "test-class1");
|
|
505
|
-
$animate.removeClass(element, "test-class3");
|
|
506
|
-
$animate.addClass(element, "test-class3");
|
|
456
|
+
expect(element[0].classList.contains("test3")).toBeTrue();
|
|
507
457
|
});
|
|
508
|
-
expect(log).toEqual(["addClass(test-class2)"]);
|
|
509
|
-
});
|
|
510
458
|
|
|
511
|
-
|
|
512
|
-
|
|
459
|
+
it("should defer class manipulation until end of digest for SVG", () => {
|
|
460
|
+
if (!window.SVGElement) return;
|
|
513
461
|
|
|
514
|
-
|
|
515
|
-
|
|
462
|
+
element = JQLite("<svg><g></g></svg>");
|
|
463
|
+
const target = element.children().eq(0);
|
|
516
464
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
$$rAF.flush();
|
|
520
|
-
$rootScope.$digest();
|
|
521
|
-
expect(log).toEqual(["addClass(test1)", "removeClass(test2)"]);
|
|
465
|
+
$rootScope.$apply(() => {
|
|
466
|
+
$animate.addClass(target, "test-class1");
|
|
522
467
|
|
|
523
|
-
|
|
524
|
-
element = JQLite('<p class="test4">test</p>');
|
|
468
|
+
$animate.removeClass(target, "test-class1");
|
|
525
469
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
$animate
|
|
529
|
-
.removeClass(element, "test4")
|
|
530
|
-
.then(log.fn("removeClass(test4)"));
|
|
531
|
-
});
|
|
470
|
+
$animate.addClass(target, "test-class2");
|
|
471
|
+
expect(target[0].classList.contains("test-class2")).toBeFalse();
|
|
532
472
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
473
|
+
$animate.setClass(target, "test-class3", "test-class4");
|
|
474
|
+
expect(target[0].classList.contains("test-class3")).toBeFalse();
|
|
475
|
+
expect(target[0].classList.contains("test-class4")).toBeFalse();
|
|
476
|
+
});
|
|
537
477
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
setupClassManipulationSpies();
|
|
541
|
-
element = JQLite("<svg><g></g></svg>");
|
|
542
|
-
const target = element.children().eq(0);
|
|
478
|
+
expect(target[0].classList.contains("test-class2")).toBeTrue();
|
|
479
|
+
});
|
|
543
480
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
expect(target).not.toHaveClass("test-class1");
|
|
481
|
+
it("should defer class manipulation until postDigest when outside of digest for SVG", () => {
|
|
482
|
+
if (!window.SVGElement) return;
|
|
547
483
|
|
|
484
|
+
element = JQLite('<svg><g class="test-class4"></g></svg>');
|
|
485
|
+
const target = element.children().eq(0);
|
|
486
|
+
debugger;
|
|
487
|
+
$animate.addClass(target, "test-class1");
|
|
548
488
|
$animate.removeClass(target, "test-class1");
|
|
549
|
-
|
|
550
489
|
$animate.addClass(target, "test-class2");
|
|
551
|
-
expect(target).not.toHaveClass("test-class2");
|
|
552
|
-
|
|
553
490
|
$animate.setClass(target, "test-class3", "test-class4");
|
|
554
|
-
expect(target).not.toHaveClass("test-class3");
|
|
555
|
-
expect(target).not.toHaveClass("test-class4");
|
|
556
|
-
});
|
|
557
|
-
|
|
558
|
-
expect(target).not.toHaveClass("test-class1");
|
|
559
|
-
expect(target).toHaveClass("test-class2");
|
|
560
|
-
expect(addClass).toHaveBeenCalledTimes(1);
|
|
561
|
-
expect(removeClass).not.toHaveBeenCalled();
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
it("should defer class manipulation until postDigest when outside of digest for SVG", () => {
|
|
565
|
-
if (!window.SVGElement) return;
|
|
566
|
-
setupClassManipulationLogger(log);
|
|
567
|
-
element = JQLite('<svg><g class="test-class4"></g></svg>');
|
|
568
|
-
const target = element.children().eq(0);
|
|
569
491
|
|
|
570
|
-
|
|
571
|
-
$animate.removeClass(target, "test-class1");
|
|
572
|
-
$animate.addClass(target, "test-class2");
|
|
573
|
-
$animate.setClass(target, "test-class3", "test-class4");
|
|
492
|
+
$rootScope.$digest();
|
|
574
493
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
expect(log).toEqual([
|
|
579
|
-
"addClass(test-class2 test-class3)",
|
|
580
|
-
"removeClass(test-class4)",
|
|
581
|
-
]);
|
|
582
|
-
expect(target).not.toHaveClass("test-class1");
|
|
583
|
-
expect(target).toHaveClass("test-class2");
|
|
584
|
-
expect(target).toHaveClass("test-class3");
|
|
585
|
-
expect(addClass).toHaveBeenCalledTimes(1);
|
|
586
|
-
expect(removeClass).toHaveBeenCalledTimes(1);
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
it("should perform class manipulation in expected order at end of digest for SVG", () => {
|
|
590
|
-
if (!window.SVGElement) return;
|
|
591
|
-
element = JQLite('<svg><g class="test-class3"></g></svg>');
|
|
592
|
-
const target = element.children().eq(0);
|
|
593
|
-
|
|
594
|
-
setupClassManipulationLogger(log);
|
|
494
|
+
expect(target[0].classList.contains("test-class2")).toBeTrue();
|
|
495
|
+
expect(target[0].classList.contains("test-class3")).toBeTrue();
|
|
496
|
+
});
|
|
595
497
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
$
|
|
498
|
+
it("should perform class manipulation in expected order at end of digest for SVG", () => {
|
|
499
|
+
if (!window.SVGElement) return;
|
|
500
|
+
element = JQLite('<svg><g class="test-class3"></g></svg>');
|
|
501
|
+
const target = element.children().eq(0);
|
|
502
|
+
|
|
503
|
+
$rootScope.$apply(() => {
|
|
504
|
+
$animate.addClass(target, "test-class1");
|
|
505
|
+
$animate.addClass(target, "test-class2");
|
|
506
|
+
$animate.removeClass(target, "test-class1");
|
|
507
|
+
$animate.removeClass(target, "test-class3");
|
|
508
|
+
$animate.addClass(target, "test-class3");
|
|
509
|
+
});
|
|
510
|
+
expect(target[0].classList.contains("test-class3")).toBeTrue();
|
|
602
511
|
});
|
|
603
|
-
expect(log).toEqual(["addClass(test-class2)"]);
|
|
604
512
|
});
|
|
605
513
|
});
|
|
606
514
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply inline styles to element
|
|
3
|
+
* @param {HTMLElement} element
|
|
4
|
+
* @param {Object<string, string>} styles
|
|
5
|
+
*/
|
|
6
|
+
export function addInlineStyles(element, styles) {
|
|
7
|
+
for (const property in styles) {
|
|
8
|
+
element.style[property] = styles[property];
|
|
9
|
+
}
|
|
10
|
+
}
|