@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.
Files changed (231) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +29 -0
  3. package/.github/workflows/playwright.yml +27 -0
  4. package/CHANGELOG.md +17974 -0
  5. package/CODE_OF_CONDUCT.md +3 -0
  6. package/CONTRIBUTING.md +246 -0
  7. package/DEVELOPERS.md +488 -0
  8. package/LICENSE +22 -0
  9. package/Makefile +31 -0
  10. package/README.md +115 -0
  11. package/RELEASE.md +98 -0
  12. package/SECURITY.md +16 -0
  13. package/TRIAGING.md +135 -0
  14. package/css/angular.css +22 -0
  15. package/dist/angular-ts.cjs.js +36843 -0
  16. package/dist/angular-ts.esm.js +36841 -0
  17. package/dist/angular-ts.umd.js +36848 -0
  18. package/dist/build/angular-animate.js +4272 -0
  19. package/dist/build/angular-aria.js +426 -0
  20. package/dist/build/angular-message-format.js +1072 -0
  21. package/dist/build/angular-messages.js +829 -0
  22. package/dist/build/angular-mocks.js +3757 -0
  23. package/dist/build/angular-parse-ext.js +1275 -0
  24. package/dist/build/angular-resource.js +911 -0
  25. package/dist/build/angular-route.js +1266 -0
  26. package/dist/build/angular-sanitize.js +891 -0
  27. package/dist/build/angular-touch.js +368 -0
  28. package/dist/build/angular.js +36600 -0
  29. package/e2e/unit.spec.ts +15 -0
  30. package/images/android-chrome-192x192.png +0 -0
  31. package/images/android-chrome-512x512.png +0 -0
  32. package/images/apple-touch-icon.png +0 -0
  33. package/images/favicon-16x16.png +0 -0
  34. package/images/favicon-32x32.png +0 -0
  35. package/images/favicon.ico +0 -0
  36. package/images/site.webmanifest +1 -0
  37. package/index.html +104 -0
  38. package/package.json +47 -0
  39. package/playwright.config.ts +78 -0
  40. package/public/circle.html +1 -0
  41. package/public/my_child_directive.html +1 -0
  42. package/public/my_directive.html +1 -0
  43. package/public/my_other_directive.html +1 -0
  44. package/public/test.html +1 -0
  45. package/rollup.config.js +31 -0
  46. package/src/animations/animateCache.js +55 -0
  47. package/src/animations/animateChildrenDirective.js +105 -0
  48. package/src/animations/animateCss.js +1139 -0
  49. package/src/animations/animateCssDriver.js +291 -0
  50. package/src/animations/animateJs.js +367 -0
  51. package/src/animations/animateJsDriver.js +67 -0
  52. package/src/animations/animateQueue.js +851 -0
  53. package/src/animations/animation.js +506 -0
  54. package/src/animations/module.js +779 -0
  55. package/src/animations/ngAnimateSwap.js +119 -0
  56. package/src/animations/rafScheduler.js +50 -0
  57. package/src/animations/shared.js +378 -0
  58. package/src/constants.js +20 -0
  59. package/src/core/animate.js +845 -0
  60. package/src/core/animateCss.js +73 -0
  61. package/src/core/animateRunner.js +195 -0
  62. package/src/core/attributes.js +199 -0
  63. package/src/core/cache.js +45 -0
  64. package/src/core/compile.js +4727 -0
  65. package/src/core/controller.js +225 -0
  66. package/src/core/exceptionHandler.js +63 -0
  67. package/src/core/filter.js +146 -0
  68. package/src/core/interpolate.js +442 -0
  69. package/src/core/interval.js +188 -0
  70. package/src/core/intervalFactory.js +57 -0
  71. package/src/core/location.js +1086 -0
  72. package/src/core/parser/parse.js +2562 -0
  73. package/src/core/parser/parse.md +13 -0
  74. package/src/core/q.js +746 -0
  75. package/src/core/rootScope.js +1596 -0
  76. package/src/core/sanitizeUri.js +85 -0
  77. package/src/core/sce.js +1161 -0
  78. package/src/core/taskTrackerFactory.js +125 -0
  79. package/src/core/timeout.js +121 -0
  80. package/src/core/urlUtils.js +187 -0
  81. package/src/core/utils.js +1349 -0
  82. package/src/directive/a.js +37 -0
  83. package/src/directive/attrs.js +283 -0
  84. package/src/directive/bind.js +51 -0
  85. package/src/directive/bind.md +142 -0
  86. package/src/directive/change.js +12 -0
  87. package/src/directive/change.md +25 -0
  88. package/src/directive/cloak.js +12 -0
  89. package/src/directive/cloak.md +24 -0
  90. package/src/directive/events.js +75 -0
  91. package/src/directive/events.md +166 -0
  92. package/src/directive/form.js +725 -0
  93. package/src/directive/init.js +15 -0
  94. package/src/directive/init.md +41 -0
  95. package/src/directive/input.js +1783 -0
  96. package/src/directive/list.js +46 -0
  97. package/src/directive/list.md +22 -0
  98. package/src/directive/ngClass.js +249 -0
  99. package/src/directive/ngController.js +64 -0
  100. package/src/directive/ngCsp.js +82 -0
  101. package/src/directive/ngIf.js +134 -0
  102. package/src/directive/ngInclude.js +217 -0
  103. package/src/directive/ngModel.js +1356 -0
  104. package/src/directive/ngModelOptions.js +509 -0
  105. package/src/directive/ngOptions.js +670 -0
  106. package/src/directive/ngRef.js +90 -0
  107. package/src/directive/ngRepeat.js +650 -0
  108. package/src/directive/ngShowHide.js +255 -0
  109. package/src/directive/ngSwitch.js +178 -0
  110. package/src/directive/ngTransclude.js +98 -0
  111. package/src/directive/non-bindable.js +11 -0
  112. package/src/directive/non-bindable.md +17 -0
  113. package/src/directive/script.js +30 -0
  114. package/src/directive/select.js +624 -0
  115. package/src/directive/style.js +25 -0
  116. package/src/directive/style.md +23 -0
  117. package/src/directive/validators.js +329 -0
  118. package/src/exts/aria.js +544 -0
  119. package/src/exts/messages.js +852 -0
  120. package/src/filters/filter.js +207 -0
  121. package/src/filters/filter.md +69 -0
  122. package/src/filters/filters.js +239 -0
  123. package/src/filters/json.md +16 -0
  124. package/src/filters/limit-to.js +43 -0
  125. package/src/filters/limit-to.md +19 -0
  126. package/src/filters/order-by.js +183 -0
  127. package/src/filters/order-by.md +83 -0
  128. package/src/index.js +13 -0
  129. package/src/injector.js +1034 -0
  130. package/src/jqLite.js +1117 -0
  131. package/src/loader.js +1320 -0
  132. package/src/public.js +215 -0
  133. package/src/routeToRegExp.js +41 -0
  134. package/src/services/anchorScroll.js +135 -0
  135. package/src/services/browser.js +321 -0
  136. package/src/services/cacheFactory.js +398 -0
  137. package/src/services/cookieReader.js +72 -0
  138. package/src/services/document.js +64 -0
  139. package/src/services/http.js +1537 -0
  140. package/src/services/httpBackend.js +206 -0
  141. package/src/services/log.js +160 -0
  142. package/src/services/templateRequest.js +139 -0
  143. package/test/angular.spec.js +2153 -0
  144. package/test/aria/aria.spec.js +1245 -0
  145. package/test/binding.spec.js +504 -0
  146. package/test/build-test.html +14 -0
  147. package/test/injector.spec.js +2327 -0
  148. package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
  149. package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
  150. package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
  151. package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
  152. package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
  153. package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
  154. package/test/jasmine/jasmine-browser.json +17 -0
  155. package/test/jasmine/jasmine.json +9 -0
  156. package/test/jqlite.spec.js +2133 -0
  157. package/test/loader.spec.js +219 -0
  158. package/test/messages/messages.spec.js +1146 -0
  159. package/test/min-err.spec.js +174 -0
  160. package/test/mock-test.html +13 -0
  161. package/test/module-test.html +15 -0
  162. package/test/ng/anomate.spec.js +606 -0
  163. package/test/ng/cache-factor.spec.js +334 -0
  164. package/test/ng/compile.spec.js +17956 -0
  165. package/test/ng/controller-provider.spec.js +227 -0
  166. package/test/ng/cookie-reader.spec.js +98 -0
  167. package/test/ng/directive/a.spec.js +192 -0
  168. package/test/ng/directive/bind.spec.js +334 -0
  169. package/test/ng/directive/boolean.spec.js +136 -0
  170. package/test/ng/directive/change.spec.js +71 -0
  171. package/test/ng/directive/class.spec.js +858 -0
  172. package/test/ng/directive/click.spec.js +38 -0
  173. package/test/ng/directive/cloak.spec.js +44 -0
  174. package/test/ng/directive/constoller.spec.js +194 -0
  175. package/test/ng/directive/element-style.spec.js +92 -0
  176. package/test/ng/directive/event.spec.js +282 -0
  177. package/test/ng/directive/form.spec.js +1518 -0
  178. package/test/ng/directive/href.spec.js +143 -0
  179. package/test/ng/directive/if.spec.js +402 -0
  180. package/test/ng/directive/include.spec.js +828 -0
  181. package/test/ng/directive/init.spec.js +68 -0
  182. package/test/ng/directive/input.spec.js +3810 -0
  183. package/test/ng/directive/list.spec.js +170 -0
  184. package/test/ng/directive/model-options.spec.js +1008 -0
  185. package/test/ng/directive/model.spec.js +1905 -0
  186. package/test/ng/directive/non-bindable.spec.js +55 -0
  187. package/test/ng/directive/options.spec.js +3583 -0
  188. package/test/ng/directive/ref.spec.js +575 -0
  189. package/test/ng/directive/repeat.spec.js +1675 -0
  190. package/test/ng/directive/script.spec.js +52 -0
  191. package/test/ng/directive/scrset.spec.js +67 -0
  192. package/test/ng/directive/select.spec.js +2541 -0
  193. package/test/ng/directive/show-hide.spec.js +253 -0
  194. package/test/ng/directive/src.spec.js +157 -0
  195. package/test/ng/directive/style.spec.js +178 -0
  196. package/test/ng/directive/switch.spec.js +647 -0
  197. package/test/ng/directive/validators.spec.js +717 -0
  198. package/test/ng/document.spec.js +52 -0
  199. package/test/ng/filter/filter.spec.js +714 -0
  200. package/test/ng/filter/filters.spec.js +35 -0
  201. package/test/ng/filter/limit-to.spec.js +251 -0
  202. package/test/ng/filter/order-by.spec.js +891 -0
  203. package/test/ng/filter.spec.js +149 -0
  204. package/test/ng/http-backend.spec.js +398 -0
  205. package/test/ng/http.spec.js +4071 -0
  206. package/test/ng/interpolate.spec.js +642 -0
  207. package/test/ng/interval.spec.js +343 -0
  208. package/test/ng/location.spec.js +3488 -0
  209. package/test/ng/on.spec.js +229 -0
  210. package/test/ng/parse.spec.js +4655 -0
  211. package/test/ng/prop.spec.js +805 -0
  212. package/test/ng/q.spec.js +2904 -0
  213. package/test/ng/root-element.spec.js +16 -0
  214. package/test/ng/sanitize-uri.spec.js +249 -0
  215. package/test/ng/sce.spec.js +660 -0
  216. package/test/ng/scope.spec.js +3442 -0
  217. package/test/ng/template-request.spec.js +236 -0
  218. package/test/ng/timeout.spec.js +351 -0
  219. package/test/ng/url-utils.spec.js +156 -0
  220. package/test/ng/utils.spec.js +144 -0
  221. package/test/original-test.html +21 -0
  222. package/test/public.spec.js +34 -0
  223. package/test/sanitize/bing-html.spec.js +36 -0
  224. package/test/server/express.js +158 -0
  225. package/test/test-utils.js +11 -0
  226. package/tsconfig.json +17 -0
  227. package/types/angular.d.ts +138 -0
  228. package/types/global.d.ts +9 -0
  229. package/types/index.d.ts +2357 -0
  230. package/types/jqlite.d.ts +558 -0
  231. package/vite.config.js +14 -0
@@ -0,0 +1,504 @@
1
+ import { jqLite, dealoc } from "../src/jqLite";
2
+ import { publishExternalAPI } from "../src/public";
3
+ import { createInjector } from "../src/injector";
4
+ import { browserTrigger } from "./test-utils";
5
+
6
+ describe("binding", () => {
7
+ let element,
8
+ $injector,
9
+ $rootScope,
10
+ $compile,
11
+ $exceptionHandler,
12
+ $document,
13
+ errors = [];
14
+
15
+ function childNode(element, index) {
16
+ return jqLite(element[0].childNodes[index]);
17
+ }
18
+
19
+ beforeEach(function () {
20
+ errors = [];
21
+ publishExternalAPI().decorator("$exceptionHandler", function () {
22
+ return (exception, cause) => {
23
+ errors.push(exception.message);
24
+ };
25
+ });
26
+ $injector = createInjector(["ng"]);
27
+ $rootScope = $injector.get("$rootScope");
28
+ $compile = $injector.get("$compile");
29
+ $exceptionHandler = $injector.get("$exceptionHandler");
30
+ $document = $injector.get("$document");
31
+ this.compileToHtml = function (content) {
32
+ let html;
33
+ content = jqLite(content);
34
+ $compile(content)($rootScope);
35
+ html = content[0].outerHTML;
36
+ return html;
37
+ };
38
+ });
39
+
40
+ afterEach(function () {
41
+ dealoc(element);
42
+ dealoc(this.element);
43
+ });
44
+
45
+ it("BindUpdate", () => {
46
+ $compile('<div ng-init="a=123"/>')($rootScope);
47
+ $rootScope.$digest();
48
+ expect($rootScope.a).toBe(123);
49
+ });
50
+
51
+ it("ExecuteInitialization", () => {
52
+ $compile('<div ng-init="a=123">')($rootScope);
53
+ expect($rootScope.a).toBe(123);
54
+ });
55
+
56
+ it("ExecuteInitializationStatements", () => {
57
+ $compile('<div ng-init="a=123;b=345">')($rootScope);
58
+ expect($rootScope.a).toBe(123);
59
+ expect($rootScope.b).toBe(345);
60
+ });
61
+
62
+ it("ApplyTextBindings", () => {
63
+ element = $compile('<div ng-bind="model.a">x</div>')($rootScope);
64
+ $rootScope.model = { a: 123 };
65
+ $rootScope.$apply();
66
+ expect(element.text()).toBe("123");
67
+ });
68
+
69
+ it("InputTypeButtonActionExecutesInScope", () => {
70
+ let savedCalled = false;
71
+ element = $compile(
72
+ '<input type="button" ng-click="person.save()" value="Apply">',
73
+ )($rootScope);
74
+ $rootScope.person = {};
75
+ $rootScope.person.save = function () {
76
+ savedCalled = true;
77
+ };
78
+ element[0].dispatchEvent(
79
+ new MouseEvent("click", {
80
+ bubbles: true,
81
+ cancelable: true,
82
+ view: window,
83
+ }),
84
+ );
85
+ expect(savedCalled).toBe(true);
86
+ });
87
+
88
+ it("InputTypeButtonActionExecutesInScope2", () => {
89
+ let log = "";
90
+ element = $compile('<input type="image" ng-click="action()">')($rootScope);
91
+ $rootScope.action = function () {
92
+ log += "click;";
93
+ };
94
+ expect(log).toEqual("");
95
+ element[0].dispatchEvent(
96
+ new MouseEvent("click", {
97
+ bubbles: true,
98
+ cancelable: true,
99
+ view: window,
100
+ }),
101
+ );
102
+ expect(log).toEqual("click;");
103
+ });
104
+
105
+ it("ButtonElementActionExecutesInScope", () => {
106
+ let savedCalled = false;
107
+ element = $compile('<button ng-click="person.save()">Apply</button>')(
108
+ $rootScope,
109
+ );
110
+ $rootScope.person = {};
111
+ $rootScope.person.save = function () {
112
+ savedCalled = true;
113
+ };
114
+ element[0].dispatchEvent(
115
+ new MouseEvent("click", {
116
+ bubbles: true,
117
+ cancelable: true,
118
+ view: window,
119
+ }),
120
+ );
121
+ expect(savedCalled).toBe(true);
122
+ });
123
+
124
+ it("RepeaterUpdateBindings", () => {
125
+ const form = $compile(
126
+ "<ul>" +
127
+ '<LI ng-repeat="item in model.items" ng-bind="item.a"></LI>' +
128
+ "</ul>",
129
+ )($rootScope);
130
+ const items = [{ a: "A" }, { a: "B" }];
131
+ $rootScope.model = { items };
132
+
133
+ $rootScope.$apply();
134
+ expect(form[0].outerHTML).toBe(
135
+ "<ul>" +
136
+ "<!-- ngRepeat: item in model.items -->" +
137
+ '<li ng-repeat="item in model.items" ng-bind="item.a">A</li>' +
138
+ "<!-- end ngRepeat: item in model.items -->" +
139
+ '<li ng-repeat="item in model.items" ng-bind="item.a">B</li>' +
140
+ "<!-- end ngRepeat: item in model.items -->" +
141
+ "</ul>",
142
+ );
143
+
144
+ items.unshift({ a: "C" });
145
+ $rootScope.$apply();
146
+ expect(form[0].outerHTML).toBe(
147
+ "<ul>" +
148
+ "<!-- ngRepeat: item in model.items -->" +
149
+ '<li ng-repeat="item in model.items" ng-bind="item.a">C</li>' +
150
+ "<!-- end ngRepeat: item in model.items -->" +
151
+ '<li ng-repeat="item in model.items" ng-bind="item.a">A</li>' +
152
+ "<!-- end ngRepeat: item in model.items -->" +
153
+ '<li ng-repeat="item in model.items" ng-bind="item.a">B</li>' +
154
+ "<!-- end ngRepeat: item in model.items -->" +
155
+ "</ul>",
156
+ );
157
+
158
+ items.shift();
159
+ $rootScope.$apply();
160
+ expect(form[0].outerHTML).toBe(
161
+ "<ul>" +
162
+ "<!-- ngRepeat: item in model.items -->" +
163
+ '<li ng-repeat="item in model.items" ng-bind="item.a">A</li>' +
164
+ "<!-- end ngRepeat: item in model.items -->" +
165
+ '<li ng-repeat="item in model.items" ng-bind="item.a">B</li>' +
166
+ "<!-- end ngRepeat: item in model.items -->" +
167
+ "</ul>",
168
+ );
169
+
170
+ items.shift();
171
+ items.shift();
172
+ $rootScope.$apply();
173
+ });
174
+
175
+ it("RepeaterContentDoesNotBind", () => {
176
+ element = $compile(
177
+ "<ul>" +
178
+ '<LI ng-repeat="item in model.items"><span ng-bind="item.a"></span></li>' +
179
+ "</ul>",
180
+ )($rootScope);
181
+ $rootScope.model = { items: [{ a: "A" }] };
182
+ $rootScope.$apply();
183
+ expect(element[0].outerHTML).toBe(
184
+ "<ul>" +
185
+ "<!-- ngRepeat: item in model.items -->" +
186
+ '<li ng-repeat="item in model.items"><span ng-bind="item.a">A</span></li>' +
187
+ "<!-- end ngRepeat: item in model.items -->" +
188
+ "</ul>",
189
+ );
190
+ });
191
+
192
+ it("DoNotOverwriteCustomAction", function () {
193
+ const html = this.compileToHtml(
194
+ '<input type="submit" value="Save" action="foo();">',
195
+ );
196
+ expect(html.indexOf('action="foo();"')).toBeGreaterThan(0);
197
+ });
198
+
199
+ it("ItShouldRemoveExtraChildrenWhenIteratingOverHash", () => {
200
+ element = $compile('<div><div ng-repeat="i in items">{{i}}</div></div>')(
201
+ $rootScope,
202
+ );
203
+ const items = {};
204
+ $rootScope.items = items;
205
+
206
+ $rootScope.$apply();
207
+ expect(element[0].childNodes.length).toEqual(1);
208
+
209
+ items.name = "misko";
210
+ $rootScope.$apply();
211
+ expect(element[0].childNodes.length).toEqual(3);
212
+
213
+ delete items.name;
214
+ $rootScope.$apply();
215
+ expect(element[0].childNodes.length).toEqual(1);
216
+ });
217
+
218
+ it("IfAttrBindingThrowsErrorDecorateTheAttribute", () => {
219
+ $compile(
220
+ '<div attr="before {{error.throw()}} after"></div>',
221
+ null,
222
+ true,
223
+ )($rootScope);
224
+ let count = 0;
225
+
226
+ $rootScope.error = {
227
+ throw: function () {
228
+ throw new Error(`ErrorMsg${++count}`);
229
+ },
230
+ };
231
+ $rootScope.$apply();
232
+ expect(errors.length).not.toEqual(0);
233
+ expect(errors.shift()).toMatch(/ErrorMsg1/);
234
+ errors.length = 0;
235
+
236
+ $rootScope.error.throw = function () {
237
+ return "X";
238
+ };
239
+ $rootScope.$apply();
240
+ expect(errors.length).toMatch("0");
241
+ });
242
+
243
+ it("NestedRepeater", () => {
244
+ element = $compile(
245
+ "<div>" +
246
+ '<div ng-repeat="m in model" name="{{m.name}}">' +
247
+ '<ul name="{{i}}" ng-repeat="i in m.item"></ul>' +
248
+ "</div>" +
249
+ "</div>",
250
+ )($rootScope);
251
+
252
+ $rootScope.model = [
253
+ { name: "a", item: ["a1", "a2"] },
254
+ { name: "b", item: ["b1", "b2"] },
255
+ ];
256
+ $rootScope.$apply();
257
+
258
+ expect(element[0].outerHTML).toBe(
259
+ `<div>` +
260
+ `<!-- ngRepeat: m in model -->` +
261
+ `<div ng-repeat="m in model" name="a">` +
262
+ `<!-- ngRepeat: i in m.item -->` +
263
+ `<ul name="a1" ng-repeat="i in m.item"></ul><!-- end ngRepeat: i in m.item -->` +
264
+ `<ul name="a2" ng-repeat="i in m.item"></ul><!-- end ngRepeat: i in m.item -->` +
265
+ `</div><!-- end ngRepeat: m in model -->` +
266
+ `<div ng-repeat="m in model" name="b">` +
267
+ `<!-- ngRepeat: i in m.item -->` +
268
+ `<ul name="b1" ng-repeat="i in m.item"></ul>` +
269
+ `<!-- end ngRepeat: i in m.item -->` +
270
+ `<ul name="b2" ng-repeat="i in m.item"></ul>` +
271
+ `<!-- end ngRepeat: i in m.item --></div>` +
272
+ `<!-- end ngRepeat: m in model --></div>`,
273
+ );
274
+ });
275
+
276
+ it("HideBindingExpression", () => {
277
+ element = $compile('<div ng-hide="hidden === 3"/>')($rootScope);
278
+
279
+ $rootScope.hidden = 3;
280
+ $rootScope.$apply();
281
+
282
+ expect(element[0].classList.contains("ng-hide")).toBe(true);
283
+
284
+ $rootScope.hidden = 2;
285
+ $rootScope.$apply();
286
+ expect(element[0].classList.contains("ng-hide")).toBe(false);
287
+ });
288
+
289
+ it("HideBinding", () => {
290
+ element = $compile('<div ng-hide="hidden"/>')($rootScope);
291
+
292
+ $rootScope.hidden = "true";
293
+ $rootScope.$apply();
294
+ expect(element[0].classList.contains("ng-hide")).toBeTrue();
295
+
296
+ $rootScope.hidden = "false";
297
+ $rootScope.$apply();
298
+ expect(element[0].classList.contains("ng-hide")).toBeTrue();
299
+
300
+ $rootScope.hidden = 0;
301
+ $rootScope.$apply();
302
+ expect(element[0].classList.contains("ng-hide")).toBeFalse();
303
+
304
+ $rootScope.hidden = false;
305
+ $rootScope.$apply();
306
+ expect(element[0].classList.contains("ng-hide")).toBeFalse();
307
+
308
+ $rootScope.hidden = "";
309
+ $rootScope.$apply();
310
+ expect(element[0].classList.contains("ng-hide")).toBeFalse();
311
+ });
312
+
313
+ it("ShowBinding", () => {
314
+ element = $compile('<div ng-show="show"/>')($rootScope);
315
+
316
+ $rootScope.show = "true";
317
+ $rootScope.$apply();
318
+ expect(element[0].classList.contains("ng-hide")).toBeFalse();
319
+
320
+ $rootScope.show = "false";
321
+ $rootScope.$apply();
322
+ expect(element[0].classList.contains("ng-hide")).toBeFalse();
323
+
324
+ $rootScope.show = false;
325
+ $rootScope.$apply();
326
+ expect(element[0].classList.contains("ng-hide")).toBeTrue();
327
+
328
+ $rootScope.show = "";
329
+ $rootScope.$apply();
330
+ expect(element[0].classList.contains("ng-hide")).toBeTrue();
331
+ });
332
+
333
+ it("BindClass", () => {
334
+ element = $compile('<div ng-class="clazz"/>')($rootScope);
335
+
336
+ $rootScope.clazz = "testClass";
337
+ $rootScope.$apply();
338
+
339
+ expect(element[0].classList.contains("testClass")).toBeTrue();
340
+
341
+ $rootScope.clazz = ["a", "b"];
342
+ $rootScope.$apply();
343
+ expect(element[0].classList.contains("a")).toBeTrue();
344
+ expect(element[0].classList.contains("b")).toBeTrue();
345
+ });
346
+
347
+ it("BindClassEvenOdd", () => {
348
+ element = $compile(
349
+ "<div>" +
350
+ '<div ng-repeat="i in [0,1]" ng-class-even="\'e\'" ng-class-odd="\'o\'"></div>' +
351
+ "</div>",
352
+ )($rootScope);
353
+ $rootScope.$apply();
354
+
355
+ const d1 = jqLite(element[0].childNodes[1]);
356
+ const d2 = jqLite(element[0].childNodes[3]);
357
+ expect(d1[0].classList.contains("o")).toBeTruthy();
358
+ expect(d2[0].classList.contains("e")).toBeTruthy();
359
+ // expect(element).toBe(
360
+ // "<div>" +
361
+ // "<!-- ngRepeat: i in [0,1] -->" +
362
+ // '<div class="o" ng-class-even="\'e\'" ng-class-odd="\'o\'" ng-repeat="i in [0,1]"></div>' +
363
+ // "<!-- end ngRepeat: i in [0,1] -->" +
364
+ // '<div class="e" ng-class-even="\'e\'" ng-class-odd="\'o\'" ng-repeat="i in [0,1]"></div>' +
365
+ // "<!-- end ngRepeat: i in [0,1] -->" +
366
+ // "</div>",
367
+ //);
368
+ });
369
+
370
+ it("BindStyle", () => {
371
+ element = $compile('<div ng-style="style"/>')($rootScope);
372
+
373
+ $rootScope.$eval('style={height: "10px"}');
374
+ $rootScope.$apply();
375
+
376
+ expect(element[0].style["height"]).toBe("10px");
377
+
378
+ $rootScope.$eval("style={}");
379
+ $rootScope.$apply();
380
+ });
381
+
382
+ it("ActionOnAHrefThrowsError", () => {
383
+ const input = $compile('<a ng-click="action()">Add Phone</a>')($rootScope);
384
+ $rootScope.action = function () {
385
+ throw new Error("MyError");
386
+ };
387
+ input[0].dispatchEvent(
388
+ new MouseEvent("click", {
389
+ bubbles: true,
390
+ cancelable: true,
391
+ view: window,
392
+ }),
393
+ );
394
+
395
+ expect(errors[0]).toMatch(/MyError/);
396
+ });
397
+
398
+ it("ShouldIgnoreVbNonBindable", () => {
399
+ element = $compile(
400
+ "<div>{{a}}" +
401
+ "<div ng-non-bindable>{{a}}</div>" +
402
+ "<div ng-non-bindable=''>{{b}}</div>" +
403
+ "<div ng-non-bindable='true'>{{c}}</div>" +
404
+ "</div>",
405
+ )($rootScope);
406
+ $rootScope.a = 123;
407
+ $rootScope.$apply();
408
+ expect(element.text()).toBe("123{{a}}{{b}}{{c}}");
409
+ });
410
+
411
+ it("ShouldTemplateBindPreElements", () => {
412
+ element = $compile("<pre>Hello {{name}}!</pre>")($rootScope);
413
+ $rootScope.name = "World";
414
+ $rootScope.$apply();
415
+
416
+ expect(element[0].outerHTML).toBe(`<pre>Hello World!</pre>`);
417
+ });
418
+
419
+ it("FillInOptionValueWhenMissing", () => {
420
+ element = $compile(
421
+ '<select ng-model="foo">' +
422
+ '<option selected="true">{{a}}</option>' +
423
+ '<option value="">{{b}}</option>' +
424
+ "<option>C</option>" +
425
+ "</select>",
426
+ )($rootScope);
427
+ $rootScope.a = "A";
428
+ $rootScope.b = "B";
429
+ $rootScope.$apply();
430
+ const optionA = childNode(element, 0);
431
+ const optionB = childNode(element, 1);
432
+ const optionC = childNode(element, 2);
433
+
434
+ expect(optionA.attr("value")).toEqual("A");
435
+ expect(optionA.text()).toEqual("A");
436
+
437
+ expect(optionB.attr("value")).toEqual("");
438
+ expect(optionB.text()).toEqual("B");
439
+
440
+ expect(optionC.attr("value")).toEqual("C");
441
+ expect(optionC.text()).toEqual("C");
442
+ });
443
+
444
+ it("ItShouldSelectTheCorrectRadioBox", () => {
445
+ element = $compile(
446
+ "<div>" +
447
+ '<input type="radio" ng-model="sex" value="female">' +
448
+ '<input type="radio" ng-model="sex" value="male">' +
449
+ "</div>",
450
+ )($rootScope);
451
+ const female = jqLite(element[0].childNodes[0]);
452
+ const male = jqLite(element[0].childNodes[1]);
453
+
454
+ female[0].click();
455
+ browserTrigger(female, "change");
456
+ expect($rootScope.sex).toBe("female");
457
+ expect(female[0].checked).toBe(true);
458
+ expect(male[0].checked).toBe(false);
459
+ expect(female.val()).toBe("female");
460
+
461
+ male[0].click();
462
+ browserTrigger(male, "change");
463
+ expect($rootScope.sex).toBe("male");
464
+ expect(female[0].checked).toBe(false);
465
+ expect(male[0].checked).toBe(true);
466
+ expect(male.val()).toBe("male");
467
+ });
468
+
469
+ it("ItShouldRepeatOnHashes", () => {
470
+ element = $compile(
471
+ "<ul>" +
472
+ '<li ng-repeat="(k,v) in {a:0,b:1}" ng-bind="k + v"></li>' +
473
+ "</ul>",
474
+ )($rootScope);
475
+ $rootScope.$apply();
476
+ expect(element[0].outerHTML).toBe(
477
+ "<ul>" +
478
+ "<!-- ngRepeat: (k,v) in {a:0,b:1} -->" +
479
+ '<li ng-repeat="(k,v) in {a:0,b:1}" ng-bind="k + v">a0</li>' +
480
+ "<!-- end ngRepeat: (k,v) in {a:0,b:1} -->" +
481
+ '<li ng-repeat="(k,v) in {a:0,b:1}" ng-bind="k + v">b1</li>' +
482
+ "<!-- end ngRepeat: (k,v) in {a:0,b:1} -->" +
483
+ "</ul>",
484
+ );
485
+ });
486
+
487
+ it("ItShouldFireChangeListenersBeforeUpdate", () => {
488
+ element = $compile('<div ng-bind="name"></div>')($rootScope);
489
+ $rootScope.name = "";
490
+ $rootScope.$watch("watched", () => {
491
+ $rootScope.name = 123;
492
+ });
493
+ $rootScope.watched = "change";
494
+ $rootScope.$apply();
495
+ expect($rootScope.name).toBe(123);
496
+ expect(element[0].outerHTML).toBe('<div ng-bind="name">123</div>');
497
+ });
498
+
499
+ it("ItShouldHandleMultilineBindings", () => {
500
+ element = $compile("<div>{{\n 1 \n + \n 2 \n}}</div>")($rootScope);
501
+ $rootScope.$apply();
502
+ expect(element.text()).toBe("3");
503
+ });
504
+ });
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html ng-app>
3
+ <head>
4
+ <script src="../dist/angular-ts.umd.js"></script>
5
+ </head>
6
+ <body>
7
+ <div>
8
+ <label>Name:</label>
9
+ <input type="text" ng-model="yourName" placeholder="Enter a name here" />
10
+ <hr />
11
+ <h1>Hello {{yourName}}!</h1>
12
+ </div>
13
+ </body>
14
+ </html>