@angular-wave/angular.ts 0.0.1
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/.eslintignore +1 -0
- package/.eslintrc.cjs +29 -0
- package/.github/workflows/playwright.yml +27 -0
- package/CHANGELOG.md +17974 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +246 -0
- package/DEVELOPERS.md +488 -0
- package/LICENSE +22 -0
- package/Makefile +31 -0
- package/README.md +115 -0
- package/RELEASE.md +98 -0
- package/SECURITY.md +16 -0
- package/TRIAGING.md +135 -0
- package/css/angular.css +22 -0
- package/dist/angular-ts.cjs.js +36843 -0
- package/dist/angular-ts.esm.js +36841 -0
- package/dist/angular-ts.umd.js +36848 -0
- package/dist/build/angular-animate.js +4272 -0
- package/dist/build/angular-aria.js +426 -0
- package/dist/build/angular-message-format.js +1072 -0
- package/dist/build/angular-messages.js +829 -0
- package/dist/build/angular-mocks.js +3757 -0
- package/dist/build/angular-parse-ext.js +1275 -0
- package/dist/build/angular-resource.js +911 -0
- package/dist/build/angular-route.js +1266 -0
- package/dist/build/angular-sanitize.js +891 -0
- package/dist/build/angular-touch.js +368 -0
- package/dist/build/angular.js +36600 -0
- package/e2e/unit.spec.ts +15 -0
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +1 -0
- package/index.html +104 -0
- package/package.json +47 -0
- package/playwright.config.ts +78 -0
- package/public/circle.html +1 -0
- package/public/my_child_directive.html +1 -0
- package/public/my_directive.html +1 -0
- package/public/my_other_directive.html +1 -0
- package/public/test.html +1 -0
- package/rollup.config.js +31 -0
- package/src/animations/animateCache.js +55 -0
- package/src/animations/animateChildrenDirective.js +105 -0
- package/src/animations/animateCss.js +1139 -0
- package/src/animations/animateCssDriver.js +291 -0
- package/src/animations/animateJs.js +367 -0
- package/src/animations/animateJsDriver.js +67 -0
- package/src/animations/animateQueue.js +851 -0
- package/src/animations/animation.js +506 -0
- package/src/animations/module.js +779 -0
- package/src/animations/ngAnimateSwap.js +119 -0
- package/src/animations/rafScheduler.js +50 -0
- package/src/animations/shared.js +378 -0
- package/src/constants.js +20 -0
- package/src/core/animate.js +845 -0
- package/src/core/animateCss.js +73 -0
- package/src/core/animateRunner.js +195 -0
- package/src/core/attributes.js +199 -0
- package/src/core/cache.js +45 -0
- package/src/core/compile.js +4727 -0
- package/src/core/controller.js +225 -0
- package/src/core/exceptionHandler.js +63 -0
- package/src/core/filter.js +146 -0
- package/src/core/interpolate.js +442 -0
- package/src/core/interval.js +188 -0
- package/src/core/intervalFactory.js +57 -0
- package/src/core/location.js +1086 -0
- package/src/core/parser/parse.js +2562 -0
- package/src/core/parser/parse.md +13 -0
- package/src/core/q.js +746 -0
- package/src/core/rootScope.js +1596 -0
- package/src/core/sanitizeUri.js +85 -0
- package/src/core/sce.js +1161 -0
- package/src/core/taskTrackerFactory.js +125 -0
- package/src/core/timeout.js +121 -0
- package/src/core/urlUtils.js +187 -0
- package/src/core/utils.js +1349 -0
- package/src/directive/a.js +37 -0
- package/src/directive/attrs.js +283 -0
- package/src/directive/bind.js +51 -0
- package/src/directive/bind.md +142 -0
- package/src/directive/change.js +12 -0
- package/src/directive/change.md +25 -0
- package/src/directive/cloak.js +12 -0
- package/src/directive/cloak.md +24 -0
- package/src/directive/events.js +75 -0
- package/src/directive/events.md +166 -0
- package/src/directive/form.js +725 -0
- package/src/directive/init.js +15 -0
- package/src/directive/init.md +41 -0
- package/src/directive/input.js +1783 -0
- package/src/directive/list.js +46 -0
- package/src/directive/list.md +22 -0
- package/src/directive/ngClass.js +249 -0
- package/src/directive/ngController.js +64 -0
- package/src/directive/ngCsp.js +82 -0
- package/src/directive/ngIf.js +134 -0
- package/src/directive/ngInclude.js +217 -0
- package/src/directive/ngModel.js +1356 -0
- package/src/directive/ngModelOptions.js +509 -0
- package/src/directive/ngOptions.js +670 -0
- package/src/directive/ngRef.js +90 -0
- package/src/directive/ngRepeat.js +650 -0
- package/src/directive/ngShowHide.js +255 -0
- package/src/directive/ngSwitch.js +178 -0
- package/src/directive/ngTransclude.js +98 -0
- package/src/directive/non-bindable.js +11 -0
- package/src/directive/non-bindable.md +17 -0
- package/src/directive/script.js +30 -0
- package/src/directive/select.js +624 -0
- package/src/directive/style.js +25 -0
- package/src/directive/style.md +23 -0
- package/src/directive/validators.js +329 -0
- package/src/exts/aria.js +544 -0
- package/src/exts/messages.js +852 -0
- package/src/filters/filter.js +207 -0
- package/src/filters/filter.md +69 -0
- package/src/filters/filters.js +239 -0
- package/src/filters/json.md +16 -0
- package/src/filters/limit-to.js +43 -0
- package/src/filters/limit-to.md +19 -0
- package/src/filters/order-by.js +183 -0
- package/src/filters/order-by.md +83 -0
- package/src/index.js +13 -0
- package/src/injector.js +1034 -0
- package/src/jqLite.js +1117 -0
- package/src/loader.js +1320 -0
- package/src/public.js +215 -0
- package/src/routeToRegExp.js +41 -0
- package/src/services/anchorScroll.js +135 -0
- package/src/services/browser.js +321 -0
- package/src/services/cacheFactory.js +398 -0
- package/src/services/cookieReader.js +72 -0
- package/src/services/document.js +64 -0
- package/src/services/http.js +1537 -0
- package/src/services/httpBackend.js +206 -0
- package/src/services/log.js +160 -0
- package/src/services/templateRequest.js +139 -0
- package/test/angular.spec.js +2153 -0
- package/test/aria/aria.spec.js +1245 -0
- package/test/binding.spec.js +504 -0
- package/test/build-test.html +14 -0
- package/test/injector.spec.js +2327 -0
- package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
- package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
- package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
- package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
- package/test/jasmine/jasmine-browser.json +17 -0
- package/test/jasmine/jasmine.json +9 -0
- package/test/jqlite.spec.js +2133 -0
- package/test/loader.spec.js +219 -0
- package/test/messages/messages.spec.js +1146 -0
- package/test/min-err.spec.js +174 -0
- package/test/mock-test.html +13 -0
- package/test/module-test.html +15 -0
- package/test/ng/anomate.spec.js +606 -0
- package/test/ng/cache-factor.spec.js +334 -0
- package/test/ng/compile.spec.js +17956 -0
- package/test/ng/controller-provider.spec.js +227 -0
- package/test/ng/cookie-reader.spec.js +98 -0
- package/test/ng/directive/a.spec.js +192 -0
- package/test/ng/directive/bind.spec.js +334 -0
- package/test/ng/directive/boolean.spec.js +136 -0
- package/test/ng/directive/change.spec.js +71 -0
- package/test/ng/directive/class.spec.js +858 -0
- package/test/ng/directive/click.spec.js +38 -0
- package/test/ng/directive/cloak.spec.js +44 -0
- package/test/ng/directive/constoller.spec.js +194 -0
- package/test/ng/directive/element-style.spec.js +92 -0
- package/test/ng/directive/event.spec.js +282 -0
- package/test/ng/directive/form.spec.js +1518 -0
- package/test/ng/directive/href.spec.js +143 -0
- package/test/ng/directive/if.spec.js +402 -0
- package/test/ng/directive/include.spec.js +828 -0
- package/test/ng/directive/init.spec.js +68 -0
- package/test/ng/directive/input.spec.js +3810 -0
- package/test/ng/directive/list.spec.js +170 -0
- package/test/ng/directive/model-options.spec.js +1008 -0
- package/test/ng/directive/model.spec.js +1905 -0
- package/test/ng/directive/non-bindable.spec.js +55 -0
- package/test/ng/directive/options.spec.js +3583 -0
- package/test/ng/directive/ref.spec.js +575 -0
- package/test/ng/directive/repeat.spec.js +1675 -0
- package/test/ng/directive/script.spec.js +52 -0
- package/test/ng/directive/scrset.spec.js +67 -0
- package/test/ng/directive/select.spec.js +2541 -0
- package/test/ng/directive/show-hide.spec.js +253 -0
- package/test/ng/directive/src.spec.js +157 -0
- package/test/ng/directive/style.spec.js +178 -0
- package/test/ng/directive/switch.spec.js +647 -0
- package/test/ng/directive/validators.spec.js +717 -0
- package/test/ng/document.spec.js +52 -0
- package/test/ng/filter/filter.spec.js +714 -0
- package/test/ng/filter/filters.spec.js +35 -0
- package/test/ng/filter/limit-to.spec.js +251 -0
- package/test/ng/filter/order-by.spec.js +891 -0
- package/test/ng/filter.spec.js +149 -0
- package/test/ng/http-backend.spec.js +398 -0
- package/test/ng/http.spec.js +4071 -0
- package/test/ng/interpolate.spec.js +642 -0
- package/test/ng/interval.spec.js +343 -0
- package/test/ng/location.spec.js +3488 -0
- package/test/ng/on.spec.js +229 -0
- package/test/ng/parse.spec.js +4655 -0
- package/test/ng/prop.spec.js +805 -0
- package/test/ng/q.spec.js +2904 -0
- package/test/ng/root-element.spec.js +16 -0
- package/test/ng/sanitize-uri.spec.js +249 -0
- package/test/ng/sce.spec.js +660 -0
- package/test/ng/scope.spec.js +3442 -0
- package/test/ng/template-request.spec.js +236 -0
- package/test/ng/timeout.spec.js +351 -0
- package/test/ng/url-utils.spec.js +156 -0
- package/test/ng/utils.spec.js +144 -0
- package/test/original-test.html +21 -0
- package/test/public.spec.js +34 -0
- package/test/sanitize/bing-html.spec.js +36 -0
- package/test/server/express.js +158 -0
- package/test/test-utils.js +11 -0
- package/tsconfig.json +17 -0
- package/types/angular.d.ts +138 -0
- package/types/global.d.ts +9 -0
- package/types/index.d.ts +2357 -0
- package/types/jqlite.d.ts +558 -0
- package/vite.config.js +14 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
describe("$animate", () => {
|
|
2
|
+
describe("without animation", () => {
|
|
3
|
+
let element;
|
|
4
|
+
let $rootElement;
|
|
5
|
+
|
|
6
|
+
beforeEach(
|
|
7
|
+
module(
|
|
8
|
+
() =>
|
|
9
|
+
function ($compile, _$rootElement_, $rootScope) {
|
|
10
|
+
element = $compile("<div></div>")($rootScope);
|
|
11
|
+
$rootElement = _$rootElement_;
|
|
12
|
+
},
|
|
13
|
+
),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
it("should add element at the start of enter animation", () => {
|
|
17
|
+
const child = $compile("<div></div>")($rootScope);
|
|
18
|
+
expect(element[0].childNodes.length).toBe(0);
|
|
19
|
+
$animate.enter(child, element);
|
|
20
|
+
expect(element[0].childNodes.length).toBe(1);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should enter the element to the start of the parent container", () => {
|
|
24
|
+
for (let i = 0; i < 5; i++) {
|
|
25
|
+
element.append(jqLite(`<div> ${i}</div>`));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const child = jqLite("<div>first</div>");
|
|
29
|
+
$animate.enter(child, element);
|
|
30
|
+
|
|
31
|
+
expect(element.text()).toEqual("first 0 1 2 3 4");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should remove the element at the end of leave animation", () => {
|
|
35
|
+
const child = $compile("<div></div>")($rootScope);
|
|
36
|
+
element.append(child);
|
|
37
|
+
expect(element[0].childNodes.length).toBe(1);
|
|
38
|
+
$animate.leave(child);
|
|
39
|
+
expect(element[0].childNodes.length).toBe(0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should reorder the move animation", () => {
|
|
43
|
+
const child1 = $compile("<div>1</div>")($rootScope);
|
|
44
|
+
const child2 = $compile("<div>2</div>")($rootScope);
|
|
45
|
+
element.append(child1);
|
|
46
|
+
element.append(child2);
|
|
47
|
+
expect(element.text()).toBe("12");
|
|
48
|
+
$animate.move(child1, element, child2);
|
|
49
|
+
expect(element.text()).toBe("21");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
fit("should apply styles instantly to the element", () => {
|
|
53
|
+
$animate.animate(element, { color: "rgb(0, 0, 0)" });
|
|
54
|
+
expect(element[0].stype.color).toBe("rgb(0, 0, 0)");
|
|
55
|
+
|
|
56
|
+
$animate.animate(
|
|
57
|
+
element,
|
|
58
|
+
{ color: "rgb(255, 0, 0)" },
|
|
59
|
+
{ color: "rgb(0, 255, 0)" },
|
|
60
|
+
);
|
|
61
|
+
expect(element[0].stype.color).toBe("rgb(0, 255, 0)");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("should still perform DOM operations even if animations are disabled (post-digest)", () => {
|
|
65
|
+
$animate.enabled(false);
|
|
66
|
+
expect(element).toBeShown();
|
|
67
|
+
$animate.addClass(element, "ng-hide");
|
|
68
|
+
$rootScope.$digest();
|
|
69
|
+
expect(element).toBeHidden();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("should run each method and return a promise", () => {
|
|
73
|
+
const element = jqLite("<div></div>");
|
|
74
|
+
const move = jqLite("<div></div>");
|
|
75
|
+
const parent = jqLite($document[0].body);
|
|
76
|
+
parent.append(move);
|
|
77
|
+
|
|
78
|
+
expect($animate.enter(element, parent)).toBeAPromise();
|
|
79
|
+
expect($animate.move(element, move)).toBeAPromise();
|
|
80
|
+
expect($animate.addClass(element, "on")).toBeAPromise();
|
|
81
|
+
expect($animate.removeClass(element, "off")).toBeAPromise();
|
|
82
|
+
expect($animate.setClass(element, "on", "off")).toBeAPromise();
|
|
83
|
+
expect($animate.leave(element)).toBeAPromise();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("should provide the `enabled` and `cancel` methods", () => {
|
|
87
|
+
expect($animate.enabled()).toBeUndefined();
|
|
88
|
+
expect($animate.cancel({})).toBeUndefined();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("should provide the `on` and `off` methods", () => {
|
|
92
|
+
expect(isFunction($animate.on)).toBe(true);
|
|
93
|
+
expect(isFunction($animate.off)).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("should add and remove classes on SVG elements", () => {
|
|
97
|
+
if (!window.SVGElement) return;
|
|
98
|
+
const svg = jqLite("<svg><rect></rect></svg>");
|
|
99
|
+
const rect = svg.children();
|
|
100
|
+
$animate.enabled(false);
|
|
101
|
+
expect(rect).toBeShown();
|
|
102
|
+
$animate.addClass(rect, "ng-hide");
|
|
103
|
+
$rootScope.$digest();
|
|
104
|
+
expect(rect).toBeHidden();
|
|
105
|
+
$animate.removeClass(rect, "ng-hide");
|
|
106
|
+
$rootScope.$digest();
|
|
107
|
+
expect(rect).not.toBeHidden();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("should throw error on wrong selector", () => {
|
|
111
|
+
module(($animateProvider) => {
|
|
112
|
+
expect(() => {
|
|
113
|
+
$animateProvider.register("abc", null);
|
|
114
|
+
}).toThrow(
|
|
115
|
+
"$animate",
|
|
116
|
+
"notcsel",
|
|
117
|
+
"Expecting class selector starting with '.' got 'abc'.",
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should register the animation and be available for lookup", () => {
|
|
123
|
+
let provider;
|
|
124
|
+
module(($animateProvider) => {
|
|
125
|
+
provider = $animateProvider;
|
|
126
|
+
});
|
|
127
|
+
() => {
|
|
128
|
+
// by using hasOwnProperty we know for sure that the lookup object is an empty object
|
|
129
|
+
// instead of inheriting properties from its original prototype.
|
|
130
|
+
expect(provider.$$registeredAnimations.hasOwnProperty).toBeFalsy();
|
|
131
|
+
|
|
132
|
+
provider.register(".filter", () => {});
|
|
133
|
+
expect(provider.$$registeredAnimations.filter).toBe(
|
|
134
|
+
".filter-animation",
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("should apply and retain inline styles on the element that is animated", () => {
|
|
140
|
+
const element = jqLite("<div></div>");
|
|
141
|
+
const parent = jqLite("<div></div>");
|
|
142
|
+
const other = jqLite("<div></div>");
|
|
143
|
+
parent.append(other);
|
|
144
|
+
$animate.enabled(true);
|
|
145
|
+
|
|
146
|
+
$animate.enter(element, parent, null, {
|
|
147
|
+
to: { color: "red" },
|
|
148
|
+
});
|
|
149
|
+
assertColor("red");
|
|
150
|
+
|
|
151
|
+
$animate.move(element, null, other, {
|
|
152
|
+
to: { color: "yellow" },
|
|
153
|
+
});
|
|
154
|
+
assertColor("yellow");
|
|
155
|
+
|
|
156
|
+
$animate.addClass(element, "on", {
|
|
157
|
+
to: { color: "green" },
|
|
158
|
+
});
|
|
159
|
+
$rootScope.$digest();
|
|
160
|
+
assertColor("green");
|
|
161
|
+
|
|
162
|
+
$animate.setClass(element, "off", "on", {
|
|
163
|
+
to: { color: "black" },
|
|
164
|
+
});
|
|
165
|
+
$rootScope.$digest();
|
|
166
|
+
assertColor("black");
|
|
167
|
+
|
|
168
|
+
$animate.removeClass(element, "off", {
|
|
169
|
+
to: { color: "blue" },
|
|
170
|
+
});
|
|
171
|
+
$rootScope.$digest();
|
|
172
|
+
assertColor("blue");
|
|
173
|
+
|
|
174
|
+
$animate.leave(element, {
|
|
175
|
+
to: { color: "yellow" },
|
|
176
|
+
});
|
|
177
|
+
$rootScope.$digest();
|
|
178
|
+
assertColor("yellow");
|
|
179
|
+
|
|
180
|
+
function assertColor(color) {
|
|
181
|
+
expect(element[0].style.color).toBe(color);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("should merge the from and to styles that are provided", () => {
|
|
186
|
+
const element = jqLite("<div></div>");
|
|
187
|
+
|
|
188
|
+
element[0].style.color = "red";
|
|
189
|
+
$animate.addClass(element, "on", {
|
|
190
|
+
from: { color: "green" },
|
|
191
|
+
to: { borderColor: "purple" },
|
|
192
|
+
});
|
|
193
|
+
$rootScope.$digest();
|
|
194
|
+
|
|
195
|
+
const { style } = element[0];
|
|
196
|
+
expect(style.color).toBe("green");
|
|
197
|
+
expect(style.borderColor).toBe("purple");
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("should avoid cancelling out add/remove when the element already contains the class", () => {
|
|
201
|
+
const element = jqLite('<div class="ng-hide"></div>');
|
|
202
|
+
|
|
203
|
+
$animate.addClass(element, "ng-hide");
|
|
204
|
+
$animate.removeClass(element, "ng-hide");
|
|
205
|
+
$rootScope.$digest();
|
|
206
|
+
|
|
207
|
+
expect(element).not.toHaveClass("ng-hide");
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("should avoid cancelling out remove/add if the element does not contain the class", () => {
|
|
211
|
+
const element = jqLite("<div></div>");
|
|
212
|
+
|
|
213
|
+
$animate.removeClass(element, "ng-hide");
|
|
214
|
+
$animate.addClass(element, "ng-hide");
|
|
215
|
+
$rootScope.$digest();
|
|
216
|
+
|
|
217
|
+
expect(element).toHaveClass("ng-hide");
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
["enter", "move"].forEach((method) => {
|
|
221
|
+
it('should accept an unwrapped "parent" element for the $prop event', () => {
|
|
222
|
+
const element = jqLite("<div></div>");
|
|
223
|
+
const parent = $document[0].createElement("div");
|
|
224
|
+
$rootElement.append(parent);
|
|
225
|
+
|
|
226
|
+
$animate[method](element, parent);
|
|
227
|
+
expect(element[0].parentNode).toBe(parent);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
["enter", "move"].forEach((method) => {
|
|
232
|
+
it('should accept an unwrapped "after" element for the $prop event', () => {
|
|
233
|
+
const element = jqLite("<div></div>");
|
|
234
|
+
const after = $document[0].createElement("div");
|
|
235
|
+
$rootElement.append(after);
|
|
236
|
+
|
|
237
|
+
$animate[method](element, null, after);
|
|
238
|
+
expect(element[0].previousSibling).toBe(after);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
[
|
|
243
|
+
"enter",
|
|
244
|
+
"move",
|
|
245
|
+
"leave",
|
|
246
|
+
"addClass",
|
|
247
|
+
"removeClass",
|
|
248
|
+
"setClass",
|
|
249
|
+
"animate",
|
|
250
|
+
].forEach((event) => {
|
|
251
|
+
it("$prop() should operate using a native DOM element", () => {
|
|
252
|
+
const captureSpy = jasmine.createSpy();
|
|
253
|
+
|
|
254
|
+
module(($provide) => {
|
|
255
|
+
$provide.value("$$animateQueue", {
|
|
256
|
+
push: captureSpy,
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
const element = jqLite("<div></div>");
|
|
261
|
+
const parent2 = jqLite("<div></div>");
|
|
262
|
+
const parent = $rootElement;
|
|
263
|
+
parent.append(parent2);
|
|
264
|
+
|
|
265
|
+
if (event !== "enter" && event !== "move") {
|
|
266
|
+
parent.append(element);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
let fn;
|
|
270
|
+
const invalidOptions = function () {};
|
|
271
|
+
|
|
272
|
+
switch (event) {
|
|
273
|
+
case "enter":
|
|
274
|
+
case "move":
|
|
275
|
+
fn = function () {
|
|
276
|
+
$animate[event](element, parent, parent2, invalidOptions);
|
|
277
|
+
};
|
|
278
|
+
break;
|
|
279
|
+
|
|
280
|
+
case "addClass":
|
|
281
|
+
fn = function () {
|
|
282
|
+
$animate.addClass(element, "klass", invalidOptions);
|
|
283
|
+
};
|
|
284
|
+
break;
|
|
285
|
+
|
|
286
|
+
case "removeClass":
|
|
287
|
+
element.className = "klass";
|
|
288
|
+
fn = function () {
|
|
289
|
+
$animate.removeClass(element, "klass", invalidOptions);
|
|
290
|
+
};
|
|
291
|
+
break;
|
|
292
|
+
|
|
293
|
+
case "setClass":
|
|
294
|
+
element.className = "two";
|
|
295
|
+
fn = function () {
|
|
296
|
+
$animate.setClass(element, "one", "two", invalidOptions);
|
|
297
|
+
};
|
|
298
|
+
break;
|
|
299
|
+
|
|
300
|
+
case "leave":
|
|
301
|
+
fn = function () {
|
|
302
|
+
$animate.leave(element, invalidOptions);
|
|
303
|
+
};
|
|
304
|
+
break;
|
|
305
|
+
|
|
306
|
+
case "animate":
|
|
307
|
+
const toStyles = { color: "red" };
|
|
308
|
+
fn = function () {
|
|
309
|
+
$animate.animate(element, {}, toStyles, "klass", invalidOptions);
|
|
310
|
+
};
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
expect(() => {
|
|
315
|
+
fn();
|
|
316
|
+
$rootScope.$digest();
|
|
317
|
+
}).not.toThrow();
|
|
318
|
+
|
|
319
|
+
const optionsArg = captureSpy.calls.mostRecent().args[2];
|
|
320
|
+
expect(optionsArg).not.toBe(invalidOptions);
|
|
321
|
+
expect(isObject(optionsArg)).toBeTruthy();
|
|
322
|
+
});
|
|
323
|
+
});
|
|
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
|
+
|
|
330
|
+
const element = jqLite("<div></div>");
|
|
331
|
+
const parent = $rootElement;
|
|
332
|
+
|
|
333
|
+
$animate.enter(element, parent, null, { addClass: () => {} });
|
|
334
|
+
$rootScope.$digest();
|
|
335
|
+
expect(spy).not.toHaveBeenCalled();
|
|
336
|
+
|
|
337
|
+
$animate.leave(element, { addClass: true });
|
|
338
|
+
$rootScope.$digest();
|
|
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();
|
|
363
|
+
|
|
364
|
+
const element = jqLite("<div></div>");
|
|
365
|
+
const parent = $rootElement;
|
|
366
|
+
|
|
367
|
+
$animate.enter(element, parent, null, { removeClass: () => {} });
|
|
368
|
+
$rootScope.$digest();
|
|
369
|
+
expect(spy).not.toHaveBeenCalled();
|
|
370
|
+
|
|
371
|
+
$animate.leave(element, { removeClass: true });
|
|
372
|
+
$rootScope.$digest();
|
|
373
|
+
expect(spy).not.toHaveBeenCalled();
|
|
374
|
+
|
|
375
|
+
element[0].classList.add("fatias");
|
|
376
|
+
$animate.enter(element, parent, null, { removeClass: "fatias" });
|
|
377
|
+
$rootScope.$digest();
|
|
378
|
+
expect(spy).toHaveBeenCalled();
|
|
379
|
+
};
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it("should not alter the provided options input in any way throughout the animation", () => {
|
|
383
|
+
const element = jqLite("<div></div>");
|
|
384
|
+
const parent = $rootElement;
|
|
385
|
+
|
|
386
|
+
const initialOptions = {
|
|
387
|
+
from: { height: "50px" },
|
|
388
|
+
to: { width: "50px" },
|
|
389
|
+
addClass: "one",
|
|
390
|
+
removeClass: "two",
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
const copiedOptions = structuredClone(initialOptions);
|
|
394
|
+
expect(copiedOptions).toEqual(initialOptions);
|
|
395
|
+
|
|
396
|
+
const runner = $animate.enter(element, parent, null, copiedOptions);
|
|
397
|
+
expect(copiedOptions).toEqual(initialOptions);
|
|
398
|
+
|
|
399
|
+
$rootScope.$digest();
|
|
400
|
+
expect(copiedOptions).toEqual(initialOptions);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
describe("CSS class DOM manipulation", () => {
|
|
404
|
+
let element;
|
|
405
|
+
let addClass;
|
|
406
|
+
let removeClass;
|
|
407
|
+
|
|
408
|
+
afterEach(() => {
|
|
409
|
+
dealoc(element);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
function setupClassManipulationSpies() {
|
|
413
|
+
() => {
|
|
414
|
+
addClass = spyOn(window, "jqLiteAddClass").and.callThrough();
|
|
415
|
+
removeClass = spyOn(window, "jqLiteRemoveClass").and.callThrough();
|
|
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
|
+
);
|
|
431
|
+
|
|
432
|
+
const _removeClass = jqLiteRemoveClass;
|
|
433
|
+
removeClass = spyOn(window, "jqLiteRemoveClass").and.callFake(
|
|
434
|
+
(element, classes) => {
|
|
435
|
+
let names = classes;
|
|
436
|
+
if (Object.prototype.toString.call(classes) === "[object Array]")
|
|
437
|
+
names = classes.join(" ");
|
|
438
|
+
log(`removeClass(${names})`);
|
|
439
|
+
return _removeClass(element, classes);
|
|
440
|
+
},
|
|
441
|
+
);
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
it("should defer class manipulation until end of digest", () => {
|
|
446
|
+
setupClassManipulationLogger(log);
|
|
447
|
+
element = jqLite("<p>test</p>");
|
|
448
|
+
|
|
449
|
+
$rootScope.$apply(() => {
|
|
450
|
+
$animate.addClass(element, "test-class1");
|
|
451
|
+
expect(element).not.toHaveClass("test-class1");
|
|
452
|
+
|
|
453
|
+
$animate.removeClass(element, "test-class1");
|
|
454
|
+
|
|
455
|
+
$animate.addClass(element, "test-class2");
|
|
456
|
+
expect(element).not.toHaveClass("test-class2");
|
|
457
|
+
|
|
458
|
+
$animate.setClass(element, "test-class3", "test-class4");
|
|
459
|
+
expect(element).not.toHaveClass("test-class3");
|
|
460
|
+
expect(element).not.toHaveClass("test-class4");
|
|
461
|
+
expect(log).toEqual([]);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
expect(element).not.toHaveClass("test-class1");
|
|
465
|
+
expect(element).not.toHaveClass("test-class4");
|
|
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>');
|
|
476
|
+
|
|
477
|
+
$animate.addClass(element, "test-class1");
|
|
478
|
+
$animate.removeClass(element, "test-class1");
|
|
479
|
+
$animate.addClass(element, "test-class2");
|
|
480
|
+
$animate.setClass(element, "test-class3", "test-class4");
|
|
481
|
+
|
|
482
|
+
expect(log).toEqual([]);
|
|
483
|
+
$rootScope.$digest();
|
|
484
|
+
|
|
485
|
+
expect(log).toEqual([
|
|
486
|
+
"addClass(test-class2 test-class3)",
|
|
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
|
+
});
|
|
495
|
+
|
|
496
|
+
it("should perform class manipulation in expected order at end of digest", () => {
|
|
497
|
+
element = jqLite('<p class="test-class3">test</p>');
|
|
498
|
+
|
|
499
|
+
setupClassManipulationLogger(log);
|
|
500
|
+
|
|
501
|
+
$rootScope.$apply(() => {
|
|
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");
|
|
507
|
+
});
|
|
508
|
+
expect(log).toEqual(["addClass(test-class2)"]);
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("should return a promise which is resolved on a different turn", () => {
|
|
512
|
+
element = jqLite('<p class="test2">test</p>');
|
|
513
|
+
|
|
514
|
+
$animate.addClass(element, "test1").then(log.fn("addClass(test1)"));
|
|
515
|
+
$animate.removeClass(element, "test2").then(log.fn("removeClass(test2)"));
|
|
516
|
+
|
|
517
|
+
$rootScope.$digest();
|
|
518
|
+
expect(log).toEqual([]);
|
|
519
|
+
$$rAF.flush();
|
|
520
|
+
$rootScope.$digest();
|
|
521
|
+
expect(log).toEqual(["addClass(test1)", "removeClass(test2)"]);
|
|
522
|
+
|
|
523
|
+
log.reset();
|
|
524
|
+
element = jqLite('<p class="test4">test</p>');
|
|
525
|
+
|
|
526
|
+
$rootScope.$apply(() => {
|
|
527
|
+
$animate.addClass(element, "test3").then(log.fn("addClass(test3)"));
|
|
528
|
+
$animate
|
|
529
|
+
.removeClass(element, "test4")
|
|
530
|
+
.then(log.fn("removeClass(test4)"));
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
$$rAF.flush();
|
|
534
|
+
$rootScope.$digest();
|
|
535
|
+
expect(log).toEqual(["addClass(test3)", "removeClass(test4)"]);
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
it("should defer class manipulation until end of digest for SVG", () => {
|
|
539
|
+
if (!window.SVGElement) return;
|
|
540
|
+
setupClassManipulationSpies();
|
|
541
|
+
element = jqLite("<svg><g></g></svg>");
|
|
542
|
+
const target = element.children().eq(0);
|
|
543
|
+
|
|
544
|
+
$rootScope.$apply(() => {
|
|
545
|
+
$animate.addClass(target, "test-class1");
|
|
546
|
+
expect(target).not.toHaveClass("test-class1");
|
|
547
|
+
|
|
548
|
+
$animate.removeClass(target, "test-class1");
|
|
549
|
+
|
|
550
|
+
$animate.addClass(target, "test-class2");
|
|
551
|
+
expect(target).not.toHaveClass("test-class2");
|
|
552
|
+
|
|
553
|
+
$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
|
+
|
|
570
|
+
$animate.addClass(target, "test-class1");
|
|
571
|
+
$animate.removeClass(target, "test-class1");
|
|
572
|
+
$animate.addClass(target, "test-class2");
|
|
573
|
+
$animate.setClass(target, "test-class3", "test-class4");
|
|
574
|
+
|
|
575
|
+
expect(log).toEqual([]);
|
|
576
|
+
$rootScope.$digest();
|
|
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);
|
|
595
|
+
|
|
596
|
+
$rootScope.$apply(() => {
|
|
597
|
+
$animate.addClass(target, "test-class1");
|
|
598
|
+
$animate.addClass(target, "test-class2");
|
|
599
|
+
$animate.removeClass(target, "test-class1");
|
|
600
|
+
$animate.removeClass(target, "test-class3");
|
|
601
|
+
$animate.addClass(target, "test-class3");
|
|
602
|
+
});
|
|
603
|
+
expect(log).toEqual(["addClass(test-class2)"]);
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
});
|