@angular-wave/angular.ts 0.0.1 → 0.0.2

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 (70) hide show
  1. package/Makefile +1 -1
  2. package/dist/angular-ts.cjs.js +503 -1686
  3. package/dist/angular-ts.esm.js +503 -1686
  4. package/dist/angular-ts.umd.js +503 -1686
  5. package/package.json +1 -1
  6. package/src/animations/{animateCss.js → animate-css.js} +0 -1
  7. package/src/animations/animation.js +428 -431
  8. package/src/animations/module.js +9 -9
  9. package/src/core/compile.js +4 -1101
  10. package/src/core/compile.md +1192 -0
  11. package/src/core/location.js +1 -1
  12. package/src/core/utils.js +1 -1
  13. package/src/directive/a.js +1 -1
  14. package/src/directive/attrs.js +1 -1
  15. package/src/directive/csp.md +87 -0
  16. package/src/directive/input.js +3 -3
  17. package/src/directive/{ngModel.js → model.js} +1 -1
  18. package/src/directive/select.js +5 -5
  19. package/src/jqLite.js +0 -12
  20. package/src/public.js +24 -24
  21. package/src/services/log.js +66 -116
  22. package/src/services/log.md +39 -0
  23. package/test/jqlite.spec.js +0 -31
  24. package/test/messages/messages.spec.js +1 -1
  25. package/test/ng/compile.spec.js +13 -13
  26. package/test/ng/directive/model-options.spec.js +1 -1
  27. package/test/ng/directive/model.spec.js +1 -1
  28. package/test/ng/directive/options.spec.js +61 -61
  29. package/test/ng/directive/select.spec.js +22 -22
  30. package/test/ng/http-backend.spec.js +1 -1
  31. package/test/ng/on.spec.js +1 -1
  32. package/test/ng/prop.spec.js +54 -62
  33. package/test/ng/sanitize-uri.spec.js +1 -1
  34. package/test/ng/scope.spec.js +1 -1
  35. package/types/jqlite.d.ts +1 -32
  36. package/src/core/attributes.js +0 -199
  37. package/src/directive/ngCsp.js +0 -82
  38. /package/src/animations/{animateCache.js → animate-cache.js} +0 -0
  39. /package/src/animations/{animateChildrenDirective.js → animate-children-directive.js} +0 -0
  40. /package/src/animations/{animateCssDriver.js → animate-css-driver.js} +0 -0
  41. /package/src/animations/{animateJsDriver.js → animate-js-driver.js} +0 -0
  42. /package/src/animations/{animateJs.js → animate-js.js} +0 -0
  43. /package/src/animations/{animateQueue.js → animate-queue.js} +0 -0
  44. /package/src/animations/{ngAnimateSwap.js → animate-swap.js} +0 -0
  45. /package/src/animations/{rafScheduler.js → raf-scheduler.js} +0 -0
  46. /package/src/core/{animateCss.js → animate-css.js} +0 -0
  47. /package/src/core/{animateRunner.js → animate-runner.js} +0 -0
  48. /package/src/core/{exceptionHandler.js → exception-handler.js} +0 -0
  49. /package/src/core/{intervalFactory.js → interval-factory.js} +0 -0
  50. /package/src/core/{rootScope.js → root-scope.js} +0 -0
  51. /package/src/core/{sanitizeUri.js → sanitize-uri.js} +0 -0
  52. /package/src/core/{taskTrackerFactory.js → task-tracker-factory.js} +0 -0
  53. /package/src/directive/{ngClass.js → class.js} +0 -0
  54. /package/src/directive/{ngController.js → controller.js} +0 -0
  55. /package/src/directive/{ngIf.js → if.js} +0 -0
  56. /package/src/directive/{ngInclude.js → include.js} +0 -0
  57. /package/src/directive/{ngModelOptions.js → model-options.js} +0 -0
  58. /package/src/directive/{ngOptions.js → options.js} +0 -0
  59. /package/src/directive/{ngRef.js → ref.js} +0 -0
  60. /package/src/directive/{ngRepeat.js → repeat.js} +0 -0
  61. /package/src/directive/{ngShowHide.js → show-hide.js} +0 -0
  62. /package/src/directive/{ngSwitch.js → switch.js} +0 -0
  63. /package/src/directive/{ngTransclude.js → transclude.js} +0 -0
  64. /package/src/{routeToRegExp.js → route-to-reg-exp.js} +0 -0
  65. /package/src/services/{anchorScroll.js → anchor-scroll.js} +0 -0
  66. /package/src/services/{cacheFactory.js → cache-factory.js} +0 -0
  67. /package/src/services/{cookieReader.js → cookie-reader.js} +0 -0
  68. /package/src/services/{httpBackend.js → http-backend.js} +0 -0
  69. /package/src/services/{templateRequest.js → template-request.js} +0 -0
  70. /package/test/ng/{anomate.spec.js → animate.spec.js} +0 -0
@@ -31,49 +31,49 @@ describe("ngProp*", () => {
31
31
  '<button ng-prop-disabled="isDisabled">Button</button>',
32
32
  )($rootScope);
33
33
  $rootScope.$digest();
34
- expect(element.prop("disabled")).toBe(false);
34
+ expect(element[0].disabled).toBe(false);
35
35
  $rootScope.isDisabled = true;
36
36
  $rootScope.$digest();
37
- expect(element.prop("disabled")).toBe(true);
37
+ expect(element[0].disabled).toBe(true);
38
38
  $rootScope.isDisabled = false;
39
39
  $rootScope.$digest();
40
- expect(element.prop("disabled")).toBe(false);
40
+ expect(element[0].disabled).toBe(false);
41
41
  });
42
42
 
43
43
  it("should bind boolean properties (input checked)", () => {
44
44
  const element = $compile(
45
45
  '<input type="checkbox" ng-prop-checked="isChecked" />',
46
46
  )($rootScope);
47
- expect(element.prop("checked")).toBe(false);
47
+ expect(element[0].checked).toBe(false);
48
48
  $rootScope.isChecked = true;
49
49
  $rootScope.$digest();
50
- expect(element.prop("checked")).toBe(true);
50
+ expect(element[0].checked).toBe(true);
51
51
  $rootScope.isChecked = false;
52
52
  $rootScope.$digest();
53
- expect(element.prop("checked")).toBe(false);
53
+ expect(element[0].checked).toBe(false);
54
54
  });
55
55
 
56
56
  it("should bind string properties (title)", () => {
57
57
  const element = $compile('<span ng-prop-title="title" />')($rootScope);
58
58
  $rootScope.title = 123;
59
59
  $rootScope.$digest();
60
- expect(element.prop("title")).toBe("123");
60
+ expect(element[0].title).toBe("123");
61
61
  $rootScope.title = "foobar";
62
62
  $rootScope.$digest();
63
- expect(element.prop("title")).toBe("foobar");
63
+ expect(element[0].title).toBe("foobar");
64
64
  });
65
65
 
66
66
  it("should bind variable type properties", () => {
67
67
  const element = $compile('<span ng-prop-asdf="asdf" />')($rootScope);
68
68
  $rootScope.asdf = 123;
69
69
  $rootScope.$digest();
70
- expect(element.prop("asdf")).toBe(123);
70
+ expect(element[0].asdf).toBe(123);
71
71
  $rootScope.asdf = "foobar";
72
72
  $rootScope.$digest();
73
- expect(element.prop("asdf")).toBe("foobar");
73
+ expect(element[0].asdf).toBe("foobar");
74
74
  $rootScope.asdf = true;
75
75
  $rootScope.$digest();
76
- expect(element.prop("asdf")).toBe(true);
76
+ expect(element[0].asdf).toBe(true);
77
77
  });
78
78
 
79
79
  // https://github.com/angular/angular.js/issues/16797
@@ -82,24 +82,24 @@ describe("ngProp*", () => {
82
82
  // Initialize to truthy value
83
83
  $rootScope.myText = "abc";
84
84
  $rootScope.$digest();
85
- expect(element.prop("text")).toBe("abc");
85
+ expect(element[0].text).toBe("abc");
86
86
 
87
87
  // Assert various falsey values get assigned to the property
88
88
  $rootScope.myText = "";
89
89
  $rootScope.$digest();
90
- expect(element.prop("text")).toBe("");
90
+ expect(element[0].text).toBe("");
91
91
  $rootScope.myText = 0;
92
92
  $rootScope.$digest();
93
- expect(element.prop("text")).toBe(0);
93
+ expect(element[0].text).toBe(0);
94
94
  $rootScope.myText = false;
95
95
  $rootScope.$digest();
96
- expect(element.prop("text")).toBe(false);
96
+ expect(element[0].text).toBe(false);
97
97
  $rootScope.myText = undefined;
98
98
  $rootScope.$digest();
99
- expect(element.prop("text")).toBeUndefined();
99
+ expect(element[0].text).toBeUndefined();
100
100
  $rootScope.myText = null;
101
101
  $rootScope.$digest();
102
- expect(element.prop("text")).toBe(null);
102
+ expect(element[0].text).toBe(null);
103
103
  });
104
104
 
105
105
  it("should directly map special properties (class)", () => {
@@ -110,19 +110,11 @@ describe("ngProp*", () => {
110
110
  expect(element[0]).not.toHaveClass("abc");
111
111
  });
112
112
 
113
- it("should not use jQuery .prop() to avoid jQuery propFix/hooks", () => {
114
- const element = $compile('<span ng-prop-class="myText" />')($rootScope);
115
- spyOn(jqLite.prototype, "prop");
116
- $rootScope.myText = "abc";
117
- $rootScope.$digest();
118
- expect(jqLite.prototype.prop).not.toHaveBeenCalled();
119
- });
120
-
121
113
  it("should support mixed case using underscore-separated names", () => {
122
114
  const element = $compile('<span ng-prop-a_bcd_e="value" />')($rootScope);
123
115
  $rootScope.value = 123;
124
116
  $rootScope.$digest();
125
- expect(element.prop("aBcdE")).toBe(123);
117
+ expect(element[0].aBcdE).toBe(123);
126
118
  });
127
119
 
128
120
  it("should work with different prefixes", () => {
@@ -130,9 +122,9 @@ describe("ngProp*", () => {
130
122
  const element = $compile(
131
123
  '<span ng:prop:test="name" ng-Prop-test2="name" ng_Prop_test3="name"></span>',
132
124
  )($rootScope);
133
- expect(element.prop("test")).toBe("Misko");
134
- expect(element.prop("test2")).toBe("Misko");
135
- expect(element.prop("test3")).toBe("Misko");
125
+ expect(element[0].test).toBe("Misko");
126
+ expect(element[0].test2).toBe("Misko");
127
+ expect(element[0].test3).toBe("Misko");
136
128
  });
137
129
 
138
130
  it('should work with the "href" property', () => {
@@ -141,7 +133,7 @@ describe("ngProp*", () => {
141
133
  $rootScope,
142
134
  );
143
135
  $rootScope.$digest();
144
- expect(element.prop("href")).toMatch(/\/test\/test$/);
136
+ expect(element[0].href).toMatch(/\/test\/test$/);
145
137
  });
146
138
 
147
139
  it("should work if they are prefixed with x- or data- and different prefixes", () => {
@@ -150,11 +142,11 @@ describe("ngProp*", () => {
150
142
  '<span data-ng-prop-test2="name" x-ng-prop-test3="name" data-ng:prop-test4="name" ' +
151
143
  'x_ng-prop-test5="name" data:ng-prop-test6="name"></span>',
152
144
  )($rootScope);
153
- expect(element.prop("test2")).toBe("Misko");
154
- expect(element.prop("test3")).toBe("Misko");
155
- expect(element.prop("test4")).toBe("Misko");
156
- expect(element.prop("test5")).toBe("Misko");
157
- expect(element.prop("test6")).toBe("Misko");
145
+ expect(element[0].test2).toBe("Misko");
146
+ expect(element[0].test3).toBe("Misko");
147
+ expect(element[0].test4).toBe("Misko");
148
+ expect(element[0].test5).toBe("Misko");
149
+ expect(element[0].test6).toBe("Misko");
158
150
  });
159
151
 
160
152
  it("should work independently of attributes with the same name", () => {
@@ -163,7 +155,7 @@ describe("ngProp*", () => {
163
155
  );
164
156
  $rootScope.asdf = 123;
165
157
  $rootScope.$digest();
166
- expect(element.prop("asdf")).toBe(123);
158
+ expect(element[0].asdf).toBe(123);
167
159
  expect(element.attr("asdf")).toBe("foo");
168
160
  });
169
161
 
@@ -173,7 +165,7 @@ describe("ngProp*", () => {
173
165
  );
174
166
  $rootScope.asdf = 123;
175
167
  $rootScope.$digest();
176
- expect(element.prop("asdf")).toBe(123);
168
+ expect(element[0].asdf).toBe(123);
177
169
  expect(element.attr("asdf")).toBe("foo");
178
170
  });
179
171
 
@@ -239,15 +231,15 @@ describe("ngProp*", () => {
239
231
  it("should process property bindings in pre-linking phase at priority 100", () => {
240
232
  compileProvider.directive("propLog", () => ({
241
233
  compile($element, $attrs) {
242
- logs.push(`compile=${$element.prop("myName")}`);
234
+ logs.push(`compile=${$element[0].myName}`);
243
235
 
244
236
  return {
245
237
  pre($scope, $element, $attrs) {
246
- logs.push(`preLinkP0=${$element.prop("myName")}`);
238
+ logs.push(`preLinkP0=${$element[0].myName}`);
247
239
  $rootScope.name = "pre0";
248
240
  },
249
241
  post($scope, $element, $attrs) {
250
- logs.push(`postLink=${$element.prop("myName")}`);
242
+ logs.push(`postLink=${$element[0].myName}`);
251
243
  $rootScope.name = "post0";
252
244
  },
253
245
  };
@@ -259,7 +251,7 @@ describe("ngProp*", () => {
259
251
  compile() {
260
252
  return {
261
253
  pre($scope, $element, $attrs) {
262
- logs.push(`preLinkP101=${$element.prop("myName")}`);
254
+ logs.push(`preLinkP101=${$element[0].myName}`);
263
255
  $rootScope.name = "pre101";
264
256
  },
265
257
  };
@@ -270,7 +262,7 @@ describe("ngProp*", () => {
270
262
  )($rootScope);
271
263
  $rootScope.name = "loader";
272
264
  $rootScope.$apply();
273
- logs.push(`digest=${element.prop("myName")}`);
265
+ logs.push(`digest=${element[0].myName}`);
274
266
  expect(logs.join("; ")).toEqual(
275
267
  "compile=undefined; preLinkP101=undefined; preLinkP0=pre101; postLink=pre101; digest=loader",
276
268
  );
@@ -283,7 +275,7 @@ describe("ngProp*", () => {
283
275
  // So for the test use something different
284
276
  $rootScope.testUrl = $sce.trustAsMediaUrl("someuntrustedthing:foo();");
285
277
  $rootScope.$digest();
286
- expect(element.prop("src")).toEqual("someuntrustedthing:foo();");
278
+ expect(element[0].src).toEqual("someuntrustedthing:foo();");
287
279
  });
288
280
 
289
281
  it("should use $$sanitizeUri", () => {
@@ -303,7 +295,7 @@ describe("ngProp*", () => {
303
295
  $rootScope.testUrl = "someUrl";
304
296
 
305
297
  $rootScope.$apply();
306
- expect(element.prop("src")).toMatch(/^http:\/\/.*\/someSanitizedUrl$/);
298
+ expect(element[0].src).toMatch(/^http:\/\/.*\/someSanitizedUrl$/);
307
299
  expect($$sanitizeUri).toHaveBeenCalledWith($rootScope.testUrl, true);
308
300
  });
309
301
 
@@ -326,7 +318,7 @@ describe("ngProp*", () => {
326
318
  // protocol name.
327
319
  $rootScope.testUrl = $sce.trustAsMediaUrl("untrusted:foo();");
328
320
  $rootScope.$apply();
329
- expect(element.prop("src")).toBe("untrusted:foo();");
321
+ expect(element[0].src).toBe("untrusted:foo();");
330
322
  });
331
323
  });
332
324
 
@@ -335,33 +327,33 @@ describe("ngProp*", () => {
335
327
  $rootScope.testUrl = "http://example.com/image.png"; // `http` is trusted
336
328
  let element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
337
329
  $rootScope.$digest();
338
- expect(element.prop("href")).toEqual("http://example.com/image.png");
330
+ expect(element[0].href).toEqual("http://example.com/image.png");
339
331
 
340
332
  element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
341
333
  $rootScope.$digest();
342
- expect(element.prop("href")).toEqual("http://example.com/image.png");
334
+ expect(element[0].href).toEqual("http://example.com/image.png");
343
335
  });
344
336
 
345
337
  it("should accept trusted values for non-trusted URI values", () => {
346
338
  $rootScope.testUrl = $sce.trustAsUrl("javascript:foo()"); // `javascript` is not trusted
347
339
  let element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
348
340
  $rootScope.$digest();
349
- expect(element.prop("href")).toEqual("javascript:foo()");
341
+ expect(element[0].href).toEqual("javascript:foo()");
350
342
 
351
343
  element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
352
344
  $rootScope.$digest();
353
- expect(element.prop("href")).toEqual("javascript:foo()");
345
+ expect(element[0].href).toEqual("javascript:foo()");
354
346
  });
355
347
 
356
348
  it("should sanitize non-trusted values", () => {
357
349
  $rootScope.testUrl = "javascript:foo()"; // `javascript` is not trusted
358
350
  let element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
359
351
  $rootScope.$digest();
360
- expect(element.prop("href")).toEqual("unsafe:javascript:foo()");
352
+ expect(element[0].href).toEqual("unsafe:javascript:foo()");
361
353
 
362
354
  element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
363
355
  $rootScope.$digest();
364
- expect(element.prop("href")).toEqual("unsafe:javascript:foo()");
356
+ expect(element[0].href).toEqual("unsafe:javascript:foo()");
365
357
  });
366
358
 
367
359
  it("should not sanitize href on elements other than anchor", () => {
@@ -371,7 +363,7 @@ describe("ngProp*", () => {
371
363
  $rootScope.testUrl = "javascript:doEvilStuff()";
372
364
  $rootScope.$apply();
373
365
 
374
- expect(element.prop("href")).toBe("javascript:doEvilStuff()");
366
+ expect(element[0].href).toBe("javascript:doEvilStuff()");
375
367
  });
376
368
 
377
369
  it("should not sanitize properties other then those configured", () => {
@@ -379,7 +371,7 @@ describe("ngProp*", () => {
379
371
  $rootScope.testUrl = "javascript:doEvilStuff()";
380
372
  $rootScope.$apply();
381
373
 
382
- expect(element.prop("title")).toBe("javascript:doEvilStuff()");
374
+ expect(element[0].title).toBe("javascript:doEvilStuff()");
383
375
  });
384
376
 
385
377
  it("should use $$sanitizeUri", () => {
@@ -398,14 +390,14 @@ describe("ngProp*", () => {
398
390
  let element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
399
391
  $rootScope.testUrl = "someUrl";
400
392
  $rootScope.$apply();
401
- expect(element.prop("href")).toMatch(/^http:\/\/.*\/someSanitizedUrl$/);
393
+ expect(element[0].href).toMatch(/^http:\/\/.*\/someSanitizedUrl$/);
402
394
  expect($$sanitizeUri).toHaveBeenCalledWith($rootScope.testUrl, false);
403
395
 
404
396
  $$sanitizeUri.calls.reset();
405
397
 
406
398
  element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
407
399
  $rootScope.$apply();
408
- expect(element.prop("href")).toMatch(/^http:\/\/.*\/someSanitizedUrl$/);
400
+ expect(element[0].href).toMatch(/^http:\/\/.*\/someSanitizedUrl$/);
409
401
  expect($$sanitizeUri).toHaveBeenCalledWith($rootScope.testUrl, false);
410
402
  });
411
403
 
@@ -443,7 +435,7 @@ describe("ngProp*", () => {
443
435
  );
444
436
  $rootScope.testUrl = "different_page";
445
437
  $rootScope.$apply();
446
- expect(element.prop("src")).toMatch(/\/different_page$/);
438
+ expect(element[0].src).toMatch(/\/different_page$/);
447
439
  });
448
440
 
449
441
  it("should clear out src properties for a different domain", () => {
@@ -485,7 +477,7 @@ describe("ngProp*", () => {
485
477
  );
486
478
  $rootScope.$apply();
487
479
 
488
- expect(element.prop("src")).toEqual("javascript:doTrustedStuff()");
480
+ expect(element[0].src).toEqual("javascript:doTrustedStuff()");
489
481
  });
490
482
  });
491
483
 
@@ -503,7 +495,7 @@ describe("ngProp*", () => {
503
495
 
504
496
  $rootScope.testUrl = $sce.trustAsResourceUrl("https://example.com/");
505
497
  $rootScope.$apply();
506
- expect(element.prop("href")).toContain("https://example.com/");
498
+ expect(element[0].href).toContain("https://example.com/");
507
499
 
508
500
  $rootScope.testUrl = "https://not.example.com/";
509
501
  expect(() => {
@@ -527,7 +519,7 @@ describe("ngProp*", () => {
527
519
  );
528
520
  $rootScope.testUrl = "different_page";
529
521
  $rootScope.$apply();
530
- expect(element.prop("action")).toMatch(/\/different_page$/);
522
+ expect(element[0].action).toMatch(/\/different_page$/);
531
523
  });
532
524
 
533
525
  it("should clear out action property for a different domain", () => {
@@ -569,7 +561,7 @@ describe("ngProp*", () => {
569
561
  );
570
562
  $rootScope.$apply();
571
563
 
572
- expect(element.prop("action")).toEqual("javascript:doTrustedStuff()");
564
+ expect(element[0].action).toEqual("javascript:doTrustedStuff()");
573
565
  });
574
566
  });
575
567
 
@@ -599,13 +591,13 @@ describe("ngProp*", () => {
599
591
 
600
592
  $rootScope.testUrl = "./css1.css";
601
593
  $rootScope.$apply();
602
- expect(element.prop("href")).toContain("css1.css");
594
+ expect(element[0].href).toContain("css1.css");
603
595
 
604
596
  $rootScope.testUrl = $sce.trustAsResourceUrl(
605
597
  "https://elsewhere.example.org/css2.css",
606
598
  );
607
599
  $rootScope.$apply();
608
- expect(element.prop("href")).toContain(
600
+ expect(element[0].href).toContain(
609
601
  "https://elsewhere.example.org/css2.css",
610
602
  );
611
603
  });
@@ -1,4 +1,4 @@
1
- import { SanitizeUriProvider } from "../../src/core/sanitizeUri";
1
+ import { SanitizeUriProvider } from "../../src/core/sanitize-uri";
2
2
 
3
3
  describe("sanitizeUri", () => {
4
4
  let sanitizeHref;
@@ -1,4 +1,4 @@
1
- import { getQueues } from "../../src/core/rootScope";
1
+ import { getQueues } from "../../src/core/root-scope";
2
2
  import { extend, sliceArgs } from "../../src/core/utils";
3
3
  import { publishExternalAPI } from "../../src/public";
4
4
  import { createInjector } from "../../src/injector";
package/types/jqlite.d.ts CHANGED
@@ -352,38 +352,7 @@ interface JQLite {
352
352
  * @see {@link https://api.jquery.com/prepend/#prepend-function}
353
353
  */
354
354
  prepend(func: (index: number, html: string) => string | Element | JQLite): this;
355
-
356
- /**
357
- * Get the value of a property for the first element in the set of matched elements.
358
- *
359
- * @param propertyName The name of the property to get.
360
- * @see {@link https://api.jquery.com/prop/#prop-propertyName}
361
- */
362
- prop(propertyName: string): any;
363
- /**
364
- * Set one or more properties for the set of matched elements.
365
- *
366
- * @param propertyName The name of the property to set.
367
- * @param value A value to set for the property.
368
- * @see {@link https://api.jquery.com/prop/#prop-propertyName-value}
369
- */
370
- prop(propertyName: string, value: string | number | boolean): this;
371
- /**
372
- * Set one or more properties for the set of matched elements.
373
- *
374
- * @param properties An object of property-value pairs to set.
375
- * @see {@link https://api.jquery.com/prop/#prop-properties}
376
- */
377
- prop(properties: Object): this;
378
- /**
379
- * Set one or more properties for the set of matched elements.
380
- *
381
- * @param propertyName The name of the property to set.
382
- * @param func A function returning the value to set. Receives the index position of the element in the set and the old property value as arguments. Within the function, the keyword this refers to the current element.
383
- * @see {@link https://api.jquery.com/prop/#prop-propertyName-function}
384
- */
385
- prop(propertyName: string, func: (index: number, oldPropertyValue: any) => any): this;
386
-
355
+
387
356
  /**
388
357
  * Remove the set of matched elements from the DOM.
389
358
  *
@@ -1,199 +0,0 @@
1
- export class Attributes {
2
- constructor(element, attributesToCopy) {
3
- if (attributesToCopy) {
4
- const keys = Object.keys(attributesToCopy);
5
- for (let i = 0, l = keys.length; i < l; i++) {
6
- const key = keys[i];
7
- this[key] = attributesToCopy[key];
8
- }
9
- } else {
10
- this.$attr = {};
11
- }
12
-
13
- this.$$element = element;
14
- }
15
-
16
- /**
17
- * @ngdoc method
18
- * @name $compile.directive.Attributes#$normalize
19
- * @kind function
20
- *
21
- * @description
22
- * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with `x-` or
23
- * `data-`) to its normalized, camelCase form.
24
- *
25
- * Also there is special case for Moz prefix starting with upper case letter.
26
- *
27
- * For further information check out the guide on {@link guide/directive#matching-directives Matching Directives}
28
- *
29
- * @param {string} name Name to normalize
30
- */
31
- $normalize(name) {
32
- return directiveNormalize(name);
33
- }
34
-
35
- /**
36
- * @ngdoc method
37
- * @name $compile.directive.Attributes#$addClass
38
- * @kind function
39
- *
40
- * @description
41
- * Adds the CSS class value specified by the classVal parameter to the element. If animations
42
- * are enabled then an animation will be triggered for the class addition.
43
- *
44
- * @param {string} classVal The className value that will be added to the element
45
- */
46
- $addClass(classVal) {
47
- if (classVal && classVal.length > 0) {
48
- $animate.addClass(this.$$element, classVal);
49
- }
50
- }
51
-
52
- /**
53
- * @ngdoc method
54
- * @name $compile.directive.Attributes#$removeClass
55
- * @kind function
56
- *
57
- * @description
58
- * Removes the CSS class value specified by the classVal parameter from the element. If
59
- * animations are enabled then an animation will be triggered for the class removal.
60
- *
61
- * @param {string} classVal The className value that will be removed from the element
62
- */
63
- $removeClass(classVal) {
64
- if (classVal && classVal.length > 0) {
65
- $animate.removeClass(this.$$element, classVal);
66
- }
67
- }
68
-
69
- /**
70
- * @ngdoc method
71
- * @name $compile.directive.Attributes#$updateClass
72
- * @kind function
73
- *
74
- * @description
75
- * Adds and removes the appropriate CSS class values to the element based on the difference
76
- * between the new and old CSS class values (specified as newClasses and oldClasses).
77
- *
78
- * @param {string} newClasses The current CSS className value
79
- * @param {string} oldClasses The former CSS className value
80
- */
81
- $updateClass(newClasses, oldClasses) {
82
- const toAdd = tokenDifference(newClasses, oldClasses);
83
- if (toAdd && toAdd.length) {
84
- $animate.addClass(this.$$element, toAdd);
85
- }
86
-
87
- const toRemove = tokenDifference(oldClasses, newClasses);
88
- if (toRemove && toRemove.length) {
89
- $animate.removeClass(this.$$element, toRemove);
90
- }
91
- }
92
-
93
- /**
94
- * Set a normalized attribute on the element in a way such that all directives
95
- * can share the attribute. This function properly handles boolean attributes.
96
- * @param {string} key Normalized key. (ie ngAttribute)
97
- * @param {string|boolean} value The value to set. If `null` attribute will be deleted.
98
- * @param {boolean=} writeAttr If false, does not write the value to DOM element attribute.
99
- * Defaults to true.
100
- * @param {string=} attrName Optional none normalized name. Defaults to key.
101
- */
102
- $set(key, value, writeAttr = true, attrName) {
103
- const node = this.$$element[0];
104
- const booleanKey = getBooleanAttrName(node, key);
105
- const aliasedKey = ALIASED_ATTR[key];
106
- let observer = key;
107
- let nodeName;
108
-
109
- if (booleanKey) {
110
- this.$$element.prop(key, value);
111
- attrName = booleanKey;
112
- } else if (aliasedKey) {
113
- this[aliasedKey] = value;
114
- observer = aliasedKey;
115
- }
116
-
117
- this[key] = value;
118
-
119
- if (attrName) {
120
- this.$attr[key] = attrName;
121
- } else {
122
- attrName = this.$attr[key];
123
- if (!attrName) {
124
- this.$attr[key] = attrName = snakeCase(key, "-");
125
- }
126
- }
127
-
128
- nodeName = nodeName_(this.$$element);
129
-
130
- if (nodeName === "img" && key === "srcset") {
131
- this[key] = value = sanitizeSrcset(value, "$set('srcset', value)");
132
- }
133
-
134
- if (writeAttr !== false) {
135
- if (value === null || isUndefined(value)) {
136
- this.$$element[0].removeAttribute(attrName);
137
- } else if (SIMPLE_ATTR_NAME.test(attrName)) {
138
- if (booleanKey && value === false) {
139
- this.$$element[0].removeAttribute(attrName);
140
- } else {
141
- this.$$element.attr(attrName, value);
142
- }
143
- } else {
144
- setSpecialAttr(this.$$element[0], attrName, value);
145
- }
146
- }
147
-
148
- const { $$observers } = this;
149
- if ($$observers) {
150
- forEach($$observers[observer], (fn) => {
151
- try {
152
- fn(value);
153
- } catch (e) {
154
- $exceptionHandler(e);
155
- }
156
- });
157
- }
158
- }
159
-
160
- /**
161
- * @ngdoc method
162
- * @name $compile.directive.Attributes#$observe
163
- * @kind function
164
- *
165
- * @description
166
- * Observes an interpolated attribute.
167
- *
168
- * The observer function will be invoked once during the next `$digest` following
169
- * compilation. The observer is then invoked whenever the interpolated value
170
- * changes.
171
- *
172
- * @param {string} key Normalized key. (ie ngAttribute) .
173
- * @param {function(interpolatedValue)} fn Function that will be called whenever
174
- the interpolated value of the attribute changes.
175
- * See the {@link guide/interpolation#how-text-and-attribute-bindings-work Interpolation
176
- * guide} for more info.
177
- * @returns {function()} Returns a deregistration function for this observer.
178
- */
179
- $observe(key, fn) {
180
- const attrs = this;
181
- const $$observers = attrs.$$observers || (attrs.$$observers = createMap());
182
- const listeners = $$observers[key] || ($$observers[key] = []);
183
-
184
- listeners.push(fn);
185
- $rootScope.$evalAsync(() => {
186
- if (
187
- !listeners.$$inter &&
188
- Object.prototype.hasOwnProperty.call(attrs, key) &&
189
- !isUndefined(attrs[key])
190
- ) {
191
- fn(attrs[key]);
192
- }
193
- });
194
-
195
- return function () {
196
- arrayRemove(listeners, fn);
197
- };
198
- }
199
- }