@angular-wave/angular.ts 0.4.2 → 0.4.4
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 +12 -2
- package/index.html +74 -3
- package/package.json +7 -7
- package/src/angular.spec.js +1 -269
- package/src/animations/animate-css-driver.js +2 -2
- package/src/animations/animate-css.js +12 -21
- package/src/animations/animate-js-driver.js +1 -3
- package/src/animations/animate-js.js +4 -4
- package/src/animations/animate-queue.js +23 -23
- package/src/animations/animate-runner.js +4 -8
- package/src/animations/animate.md +1 -1
- package/src/animations/animate.spec.js +0 -21
- package/src/animations/animation.js +4 -4
- package/src/animations/shared.js +14 -12
- package/src/binding.spec.js +0 -1
- package/src/core/cache/cache.js +2 -29
- package/src/core/compile/attributes.js +2 -3
- package/src/core/compile/compile.js +260 -245
- package/src/core/compile/compile.spec.js +63 -317
- package/src/core/compile/compile.test.js +1 -1
- package/src/core/controller/controller.js +2 -0
- package/src/core/di/injector.md +1 -1
- package/src/core/di/injector.spec.js +0 -2
- package/src/core/di/internal-injector.js +2 -1
- package/src/core/interpolate/interpolate.js +16 -3
- package/src/core/interpolate/interpolate.spec.js +70 -16
- package/src/core/location/location.js +0 -2
- package/src/core/location/location.spec.js +27 -27
- package/src/core/{scope/scope.html → model/model.html} +1 -1
- package/src/core/model/model.js +944 -0
- package/src/core/model/model.spec.js +3012 -0
- package/src/core/on.spec.js +0 -7
- package/src/core/parse/interpreter.js +10 -7
- package/src/core/parse/parse.js +28 -7
- package/src/core/parse/parse.spec.js +95 -91
- package/src/core/prop.spec.js +4 -60
- package/src/core/sce/sce.js +1 -2
- package/src/core/sce/sce.spec.js +0 -8
- package/src/core/scope/scope.js +62 -32
- package/src/core/scope/scope.spec.js +25 -1960
- package/src/directive/aria/aria.js +3 -6
- package/src/directive/aria/aria.spec.js +0 -87
- package/src/directive/attrs/attrs.spec.js +0 -5
- package/src/directive/{list/list.test.js → attrs/attrs.test.js} +1 -1
- package/src/{core/q/q.html → directive/attrs/boolean.html} +1 -1
- package/src/directive/attrs/boolean.spec.js +0 -15
- package/src/{core/q/q.test.js → directive/attrs/boolean.test.js} +1 -2
- package/src/{core/timeout/timeout.html → directive/attrs/element-style.html} +4 -1
- package/src/directive/attrs/element-style.spec.js +0 -8
- package/src/{core/scope/scope.test.js → directive/attrs/element-style.test.js} +1 -2
- package/src/directive/attrs/src.spec.js +0 -7
- package/src/directive/bind/bind.spec.js +0 -33
- package/src/directive/bind/bing-html.spec.js +1 -4
- package/src/{core/interval/interval.html → directive/channel/channel.html} +1 -1
- package/src/directive/channel/channel.js +29 -0
- package/src/directive/channel/channel.spec.js +52 -0
- package/src/directive/channel/channel.test.js +9 -0
- package/src/directive/class/class.js +3 -3
- package/src/directive/class/class.spec.js +9 -75
- package/src/directive/controller/controller.spec.js +0 -13
- package/src/directive/events/click.spec.js +0 -3
- package/src/directive/events/event.spec.js +0 -6
- package/src/directive/form/form.js +14 -22
- package/src/directive/form/form.spec.js +0 -65
- package/src/directive/if/if.spec.js +2 -7
- package/src/directive/if/if.test.js +1 -2
- package/src/directive/include/include.js +2 -2
- package/src/directive/include/include.spec.js +8 -59
- package/src/directive/init/init.js +6 -2
- package/src/directive/init/init.spec.js +0 -2
- package/src/directive/input/input.js +1 -2
- package/src/directive/input/input.spec.js +191 -331
- package/src/directive/messages/messages.spec.js +4 -35
- package/src/directive/model/model.js +30 -42
- package/src/directive/model/model.spec.js +2 -49
- package/src/directive/model-options/model-options.js +22 -26
- package/src/directive/model-options/model-options.spec.js +0 -6
- package/src/directive/non-bindable/non-bindable.spec.js +0 -1
- package/src/directive/observe/observe.js +0 -1
- package/src/directive/observe/observe.spec.js +0 -1
- package/src/directive/options/options.js +1 -3
- package/src/directive/options/options.spec.js +3 -38
- package/src/directive/ref/href.spec.js +0 -15
- package/src/directive/repeat/repeat.js +2 -2
- package/src/directive/repeat/repeat.spec.js +56 -192
- package/src/directive/script/script.spec.js +0 -2
- package/src/directive/select/select.js +3 -3
- package/src/directive/select/select.spec.js +9 -106
- package/src/directive/show-hide/show-hide.js +2 -2
- package/src/directive/show-hide/show-hide.spec.js +8 -19
- package/src/directive/style/style.spec.js +0 -7
- package/src/directive/switch/switch.js +1 -2
- package/src/directive/switch/switch.spec.js +5 -5
- package/src/directive/validators/validators.spec.js +0 -1
- package/src/loader.js +0 -1
- package/src/public.js +75 -80
- package/src/router/common/coreservices.js +0 -2
- package/src/router/directives/state-directives.js +24 -30
- package/src/router/directives/state-directives.spec.js +0 -83
- package/src/router/directives/view-directive.js +6 -15
- package/src/router/directives/view-directive.spec.js +25 -71
- package/src/router/hooks/lazy-load.js +2 -2
- package/src/router/hooks/views.js +3 -5
- package/src/router/resolve/resolvable.js +3 -6
- package/src/router/resolve/resolve-context.js +2 -2
- package/src/router/state/state-service.js +4 -4
- package/src/router/state/state.spec.js +2 -5
- package/src/router/state/views.js +9 -12
- package/src/router/template-factory.js +3 -6
- package/src/router/template-factory.spec.js +0 -4
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/transition/transition.js +1 -1
- package/src/router/url/url-service.js +2 -8
- package/src/router/url/url-service.spec.js +3 -4
- package/src/router/view-hook.spec.js +2 -2
- package/src/router/view-scroll.js +4 -6
- package/src/services/http/http.js +11 -15
- package/src/services/http/http.spec.js +30 -31
- package/src/services/http/template-request.spec.js +0 -10
- package/src/services/http-backend/http-backend.js +19 -17
- package/src/services/http-backend/http-backend.spec.js +3 -3
- package/src/services/template-request.js +2 -4
- package/src/shared/common.js +6 -10
- package/src/shared/jqlite/jqlite.js +14 -15
- package/src/shared/jqlite/jqlite.spec.js +2 -2
- package/src/shared/utils.js +15 -92
- package/types/core/cache/cache.d.ts +1 -1
- package/types/core/model/model.d.ts +204 -0
- package/types/core/parse/parse.d.ts +26 -0
- package/types/core/scope/scope.d.ts +22 -21
- package/types/directive/channel/channel.d.ts +11 -0
- package/types/directive/form/form.d.ts +1 -0
- package/types/shared/common.d.ts +0 -1
- package/types/shared/utils.d.ts +0 -35
- package/src/core/interval/interval-factory.js +0 -50
- package/src/core/interval/interval.js +0 -77
- package/src/core/interval/interval.md +0 -123
- package/src/core/interval/interval.spec.js +0 -280
- package/src/core/q/q.js +0 -472
- package/src/core/q/q.md +0 -211
- package/src/core/q/q.spec.js +0 -2748
- package/src/core/timeout/timeout.js +0 -109
- package/src/core/timeout/timeout.spec.js +0 -354
- package/src/core/timeout/timout.test.js +0 -12
- package/src/directive/list/list.html +0 -18
- package/src/directive/list/list.js +0 -46
- package/src/directive/list/list.md +0 -22
- package/src/directive/list/list.spec.js +0 -172
- package/types/directive/list/list.d.ts +0 -4
package/src/core/prop.spec.js
CHANGED
|
@@ -34,13 +34,10 @@ fdescribe("ngProp*", () => {
|
|
|
34
34
|
const element = $compile(
|
|
35
35
|
'<button ng-prop-disabled="isDisabled">Button</button>',
|
|
36
36
|
)($rootScope);
|
|
37
|
-
$rootScope.$digest();
|
|
38
37
|
expect(element[0].disabled).toBe(false);
|
|
39
38
|
$rootScope.isDisabled = true;
|
|
40
|
-
$rootScope.$digest();
|
|
41
39
|
expect(element[0].disabled).toBe(true);
|
|
42
40
|
$rootScope.isDisabled = false;
|
|
43
|
-
$rootScope.$digest();
|
|
44
41
|
expect(element[0].disabled).toBe(false);
|
|
45
42
|
});
|
|
46
43
|
|
|
@@ -50,33 +47,26 @@ fdescribe("ngProp*", () => {
|
|
|
50
47
|
)($rootScope);
|
|
51
48
|
expect(element[0].checked).toBe(false);
|
|
52
49
|
$rootScope.isChecked = true;
|
|
53
|
-
$rootScope.$digest();
|
|
54
50
|
expect(element[0].checked).toBe(true);
|
|
55
51
|
$rootScope.isChecked = false;
|
|
56
|
-
$rootScope.$digest();
|
|
57
52
|
expect(element[0].checked).toBe(false);
|
|
58
53
|
});
|
|
59
54
|
|
|
60
55
|
it("should bind string properties (title)", () => {
|
|
61
56
|
const element = $compile('<span ng-prop-title="title" />')($rootScope);
|
|
62
57
|
$rootScope.title = 123;
|
|
63
|
-
$rootScope.$digest();
|
|
64
58
|
expect(element[0].title).toBe("123");
|
|
65
59
|
$rootScope.title = "foobar";
|
|
66
|
-
$rootScope.$digest();
|
|
67
60
|
expect(element[0].title).toBe("foobar");
|
|
68
61
|
});
|
|
69
62
|
|
|
70
63
|
it("should bind variable type properties", () => {
|
|
71
64
|
const element = $compile('<span ng-prop-asdf="asdf" />')($rootScope);
|
|
72
65
|
$rootScope.asdf = 123;
|
|
73
|
-
$rootScope.$digest();
|
|
74
66
|
expect(element[0].asdf).toBe(123);
|
|
75
67
|
$rootScope.asdf = "foobar";
|
|
76
|
-
$rootScope.$digest();
|
|
77
68
|
expect(element[0].asdf).toBe("foobar");
|
|
78
69
|
$rootScope.asdf = true;
|
|
79
|
-
$rootScope.$digest();
|
|
80
70
|
expect(element[0].asdf).toBe(true);
|
|
81
71
|
});
|
|
82
72
|
|
|
@@ -85,31 +75,24 @@ fdescribe("ngProp*", () => {
|
|
|
85
75
|
const element = $compile('<span ng-prop-text="myText" />')($rootScope);
|
|
86
76
|
// Initialize to truthy value
|
|
87
77
|
$rootScope.myText = "abc";
|
|
88
|
-
$rootScope.$digest();
|
|
89
78
|
expect(element[0].text).toBe("abc");
|
|
90
79
|
|
|
91
80
|
// Assert various falsey values get assigned to the property
|
|
92
81
|
$rootScope.myText = "";
|
|
93
|
-
$rootScope.$digest();
|
|
94
82
|
expect(element[0].text).toBe("");
|
|
95
83
|
$rootScope.myText = 0;
|
|
96
|
-
$rootScope.$digest();
|
|
97
84
|
expect(element[0].text).toBe(0);
|
|
98
85
|
$rootScope.myText = false;
|
|
99
|
-
$rootScope.$digest();
|
|
100
86
|
expect(element[0].text).toBe(false);
|
|
101
87
|
$rootScope.myText = undefined;
|
|
102
|
-
$rootScope.$digest();
|
|
103
88
|
expect(element[0].text).toBeUndefined();
|
|
104
89
|
$rootScope.myText = null;
|
|
105
|
-
$rootScope.$digest();
|
|
106
90
|
expect(element[0].text).toBe(null);
|
|
107
91
|
});
|
|
108
92
|
|
|
109
93
|
it("should directly map special properties (class)", () => {
|
|
110
94
|
const element = $compile('<span ng-prop-class="myText" />')($rootScope);
|
|
111
95
|
$rootScope.myText = "abc";
|
|
112
|
-
$rootScope.$digest();
|
|
113
96
|
expect(element[0].class).toBe("abc");
|
|
114
97
|
expect(element[0]).not.toHaveClass("abc");
|
|
115
98
|
});
|
|
@@ -117,7 +100,6 @@ fdescribe("ngProp*", () => {
|
|
|
117
100
|
it("should support mixed case using underscore-separated names", () => {
|
|
118
101
|
const element = $compile('<span ng-prop-a_bcd_e="value" />')($rootScope);
|
|
119
102
|
$rootScope.value = 123;
|
|
120
|
-
$rootScope.$digest();
|
|
121
103
|
expect(element[0].aBcdE).toBe(123);
|
|
122
104
|
});
|
|
123
105
|
|
|
@@ -136,7 +118,6 @@ fdescribe("ngProp*", () => {
|
|
|
136
118
|
const element = $compile("<a ng-prop-href=\"'test/' + value\"></a>")(
|
|
137
119
|
$rootScope,
|
|
138
120
|
);
|
|
139
|
-
$rootScope.$digest();
|
|
140
121
|
expect(element[0].href).toMatch(/\/test\/test$/);
|
|
141
122
|
});
|
|
142
123
|
|
|
@@ -158,7 +139,6 @@ fdescribe("ngProp*", () => {
|
|
|
158
139
|
$rootScope,
|
|
159
140
|
);
|
|
160
141
|
$rootScope.asdf = 123;
|
|
161
|
-
$rootScope.$digest();
|
|
162
142
|
expect(element[0].asdf).toBe(123);
|
|
163
143
|
expect(element.attr("asdf")).toBe("foo");
|
|
164
144
|
});
|
|
@@ -168,7 +148,6 @@ fdescribe("ngProp*", () => {
|
|
|
168
148
|
$rootScope,
|
|
169
149
|
);
|
|
170
150
|
$rootScope.asdf = 123;
|
|
171
|
-
$rootScope.$digest();
|
|
172
151
|
expect(element[0].asdf).toBe(123);
|
|
173
152
|
expect(element.attr("asdf")).toBe("foo");
|
|
174
153
|
});
|
|
@@ -278,7 +257,6 @@ fdescribe("ngProp*", () => {
|
|
|
278
257
|
// Some browsers complain if you try to write `javascript:` into an `img[src]`
|
|
279
258
|
// So for the test use something different
|
|
280
259
|
$rootScope.testUrl = $sce.trustAsMediaUrl("someuntrustedthing:foo();");
|
|
281
|
-
$rootScope.$digest();
|
|
282
260
|
expect(element[0].src).toEqual("someuntrustedthing:foo();");
|
|
283
261
|
});
|
|
284
262
|
|
|
@@ -330,33 +308,27 @@ fdescribe("ngProp*", () => {
|
|
|
330
308
|
it("should NOT require trusted values for trusted URI values", () => {
|
|
331
309
|
$rootScope.testUrl = "http://example.com/image.png"; // `http` is trusted
|
|
332
310
|
let element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
|
|
333
|
-
$rootScope.$digest();
|
|
334
311
|
expect(element[0].href).toEqual("http://example.com/image.png");
|
|
335
312
|
|
|
336
313
|
element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
|
|
337
|
-
$rootScope.$digest();
|
|
338
314
|
expect(element[0].href).toEqual("http://example.com/image.png");
|
|
339
315
|
});
|
|
340
316
|
|
|
341
317
|
it("should accept trusted values for non-trusted URI values", () => {
|
|
342
318
|
$rootScope.testUrl = $sce.trustAsUrl("javascript:foo()"); // `javascript` is not trusted
|
|
343
319
|
let element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
|
|
344
|
-
$rootScope.$digest();
|
|
345
320
|
expect(element[0].href).toEqual("javascript:foo()");
|
|
346
321
|
|
|
347
322
|
element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
|
|
348
|
-
$rootScope.$digest();
|
|
349
323
|
expect(element[0].href).toEqual("javascript:foo()");
|
|
350
324
|
});
|
|
351
325
|
|
|
352
326
|
it("should sanitize non-trusted values", () => {
|
|
353
327
|
$rootScope.testUrl = "javascript:foo()"; // `javascript` is not trusted
|
|
354
328
|
let element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
|
|
355
|
-
$rootScope.$digest();
|
|
356
329
|
expect(element[0].href).toEqual("unsafe:javascript:foo()");
|
|
357
330
|
|
|
358
331
|
element = $compile('<a ng-prop-href="testUrl"></a>')($rootScope);
|
|
359
|
-
$rootScope.$digest();
|
|
360
332
|
expect(element[0].href).toEqual("unsafe:javascript:foo()");
|
|
361
333
|
});
|
|
362
334
|
|
|
@@ -411,16 +383,9 @@ fdescribe("ngProp*", () => {
|
|
|
411
383
|
"<foo ng-prop-href=\"'http://example.com/' + testUrl\"></foo><foo ng-prop-href=\"::'http://example.com/' + testUrl\"></foo>",
|
|
412
384
|
)($rootScope);
|
|
413
385
|
$rootScope.testUrl = [1];
|
|
414
|
-
$rootScope.$digest();
|
|
415
|
-
|
|
416
386
|
$rootScope.testUrl = [];
|
|
417
|
-
$rootScope.$digest();
|
|
418
|
-
|
|
419
387
|
$rootScope.testUrl = { a: "b" };
|
|
420
|
-
$rootScope.$digest();
|
|
421
|
-
|
|
422
388
|
$rootScope.testUrl = {};
|
|
423
|
-
$rootScope.$digest();
|
|
424
389
|
});
|
|
425
390
|
});
|
|
426
391
|
|
|
@@ -638,7 +603,6 @@ fdescribe("ngProp*", () => {
|
|
|
638
603
|
$rootScope,
|
|
639
604
|
);
|
|
640
605
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
641
|
-
$rootScope.$digest();
|
|
642
606
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
643
607
|
});
|
|
644
608
|
|
|
@@ -647,10 +611,8 @@ fdescribe("ngProp*", () => {
|
|
|
647
611
|
$rootScope,
|
|
648
612
|
);
|
|
649
613
|
$rootScope.html = "hello";
|
|
650
|
-
$rootScope.$digest();
|
|
651
614
|
expect(element.html()).toEqual("hello");
|
|
652
615
|
$rootScope.html = "goodbye";
|
|
653
|
-
$rootScope.$digest();
|
|
654
616
|
expect(element.html()).toEqual("goodbye");
|
|
655
617
|
});
|
|
656
618
|
|
|
@@ -660,11 +622,9 @@ fdescribe("ngProp*", () => {
|
|
|
660
622
|
);
|
|
661
623
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
662
624
|
expect($rootScope.$$watchers.length).toEqual(1);
|
|
663
|
-
$rootScope.$digest();
|
|
664
625
|
expect(element.text()).toEqual("hello");
|
|
665
626
|
expect($rootScope.$$watchers.length).toEqual(0);
|
|
666
627
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
667
|
-
$rootScope.$digest();
|
|
668
628
|
expect(element.text()).toEqual("hello");
|
|
669
629
|
});
|
|
670
630
|
});
|
|
@@ -688,9 +648,7 @@ fdescribe("ngProp*", () => {
|
|
|
688
648
|
$rootScope,
|
|
689
649
|
);
|
|
690
650
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
691
|
-
expect(() => {
|
|
692
|
-
$rootScope.$digest();
|
|
693
|
-
}).toThrowError(/unsafe/);
|
|
651
|
+
expect(() => {}).toThrowError(/unsafe/);
|
|
694
652
|
});
|
|
695
653
|
|
|
696
654
|
it("should NOT set html for wrongly typed values", () => {
|
|
@@ -698,9 +656,7 @@ fdescribe("ngProp*", () => {
|
|
|
698
656
|
$rootScope,
|
|
699
657
|
);
|
|
700
658
|
$rootScope.html = $sce.trustAsCss('<div onclick="">hello</div>');
|
|
701
|
-
expect(() => {
|
|
702
|
-
$rootScope.$digest();
|
|
703
|
-
}).toThrowError(/unsafe/);
|
|
659
|
+
expect(() => {}).toThrowError(/unsafe/);
|
|
704
660
|
});
|
|
705
661
|
|
|
706
662
|
it("should set html for trusted values", () => {
|
|
@@ -708,7 +664,6 @@ fdescribe("ngProp*", () => {
|
|
|
708
664
|
$rootScope,
|
|
709
665
|
);
|
|
710
666
|
$rootScope.html = $sce.trustAsHtml('<div onclick="">hello</div>');
|
|
711
|
-
$rootScope.$digest();
|
|
712
667
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
713
668
|
});
|
|
714
669
|
|
|
@@ -717,10 +672,8 @@ fdescribe("ngProp*", () => {
|
|
|
717
672
|
$rootScope,
|
|
718
673
|
);
|
|
719
674
|
$rootScope.html = $sce.trustAsHtml("hello");
|
|
720
|
-
$rootScope.$digest();
|
|
721
675
|
expect(element.html()).toEqual("hello");
|
|
722
676
|
$rootScope.html = $sce.trustAsHtml("goodbye");
|
|
723
|
-
$rootScope.$digest();
|
|
724
677
|
expect(element.html()).toEqual("goodbye");
|
|
725
678
|
});
|
|
726
679
|
|
|
@@ -734,7 +687,6 @@ fdescribe("ngProp*", () => {
|
|
|
734
687
|
$rootScope.getHtml = function () {
|
|
735
688
|
return $sce.trustAsHtml('<div onclick="">hello</div>');
|
|
736
689
|
};
|
|
737
|
-
$rootScope.$digest();
|
|
738
690
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
739
691
|
});
|
|
740
692
|
|
|
@@ -775,10 +727,8 @@ fdescribe("ngProp*", () => {
|
|
|
775
727
|
$rootScope.getHtml = function () {
|
|
776
728
|
return $sce.trustAsHtml(html);
|
|
777
729
|
};
|
|
778
|
-
$rootScope.$digest();
|
|
779
730
|
expect(element.html()).toEqual("hello");
|
|
780
731
|
html = "goodbye";
|
|
781
|
-
$rootScope.$digest();
|
|
782
732
|
expect(element.html()).toEqual("goodbye");
|
|
783
733
|
});
|
|
784
734
|
});
|
|
@@ -788,24 +738,18 @@ fdescribe("ngProp*", () => {
|
|
|
788
738
|
it("should NOT set style for untrusted values", () => {
|
|
789
739
|
const element = $compile('<div ng-prop-style="style"></div>')($rootScope);
|
|
790
740
|
$rootScope.style = "margin-left: 10px";
|
|
791
|
-
expect(() => {
|
|
792
|
-
$rootScope.$digest();
|
|
793
|
-
}).toThrowError(/unsafe/);
|
|
741
|
+
expect(() => {}).toThrowError(/unsafe/);
|
|
794
742
|
});
|
|
795
743
|
|
|
796
744
|
it("should NOT set style for wrongly typed values", () => {
|
|
797
745
|
const element = $compile('<div ng-prop-style="style"></div>')($rootScope);
|
|
798
746
|
$rootScope.style = $sce.trustAsHtml("margin-left: 10px");
|
|
799
|
-
expect(() => {
|
|
800
|
-
$rootScope.$digest();
|
|
801
|
-
}).toThrowError(/unsafe/);
|
|
747
|
+
expect(() => {}).toThrowError(/unsafe/);
|
|
802
748
|
});
|
|
803
749
|
|
|
804
750
|
it("should set style for trusted values", () => {
|
|
805
751
|
const element = $compile('<div ng-prop-style="style"></div>')($rootScope);
|
|
806
752
|
$rootScope.style = $sce.trustAsCss("margin-left: 10px");
|
|
807
|
-
$rootScope.$digest();
|
|
808
|
-
|
|
809
753
|
expect(element[0].style["margin-left"]).toEqual("10px");
|
|
810
754
|
});
|
|
811
755
|
});
|
package/src/core/sce/sce.js
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
urlResolve,
|
|
5
5
|
} from "./../url-utils/url-utils";
|
|
6
6
|
import {
|
|
7
|
-
forEach,
|
|
8
7
|
isFunction,
|
|
9
8
|
isRegExp,
|
|
10
9
|
isString,
|
|
@@ -731,7 +730,7 @@ export function SceProvider() {
|
|
|
731
730
|
const { getTrusted } = sce;
|
|
732
731
|
const { trustAs } = sce;
|
|
733
732
|
|
|
734
|
-
forEach(
|
|
733
|
+
Object.entries(SCE_CONTEXTS).forEach(([name, enumValue]) => {
|
|
735
734
|
const lName = lowercase(name);
|
|
736
735
|
sce[snakeToCamel(`parse_as_${lName}`)] = function (expr) {
|
|
737
736
|
return parse(enumValue, expr);
|
package/src/core/sce/sce.spec.js
CHANGED
|
@@ -202,18 +202,14 @@ describe("SCE", () => {
|
|
|
202
202
|
logs.push(`${value}`);
|
|
203
203
|
});
|
|
204
204
|
|
|
205
|
-
$rootScope.$digest();
|
|
206
205
|
expect(logs[0]).toEqual("undefined"); // initial listener call
|
|
207
206
|
|
|
208
207
|
$rootScope.foo = $sce.trustAs($sce.HTML, "trustedValue");
|
|
209
208
|
expect($rootScope.$$watchers.length).toBe(1);
|
|
210
|
-
$rootScope.$digest();
|
|
211
|
-
|
|
212
209
|
expect($rootScope.$$watchers.length).toBe(0);
|
|
213
210
|
expect(logs[1]).toEqual("trustedValue");
|
|
214
211
|
|
|
215
212
|
$rootScope.foo = $sce.trustAs($sce.HTML, "anotherTrustedValue");
|
|
216
|
-
$rootScope.$digest();
|
|
217
213
|
expect(logs[2]).toBeUndefined(); // watcher no longer active
|
|
218
214
|
});
|
|
219
215
|
|
|
@@ -222,18 +218,14 @@ describe("SCE", () => {
|
|
|
222
218
|
logs.push(`${value}`);
|
|
223
219
|
});
|
|
224
220
|
|
|
225
|
-
$rootScope.$digest();
|
|
226
221
|
expect(logs[0]).toEqual("undefined"); // initial listener call
|
|
227
222
|
|
|
228
223
|
$rootScope.foo = $sce.trustAs($sce.URL, "trustedValue");
|
|
229
224
|
expect($rootScope.$$watchers.length).toBe(1);
|
|
230
|
-
$rootScope.$digest();
|
|
231
|
-
|
|
232
225
|
expect($rootScope.$$watchers.length).toBe(0);
|
|
233
226
|
expect(logs[1]).toEqual("trustedValue");
|
|
234
227
|
|
|
235
228
|
$rootScope.foo = $sce.trustAs($sce.URL, "anotherTrustedValue");
|
|
236
|
-
$rootScope.$digest();
|
|
237
229
|
expect(logs[2]).toBeUndefined(); // watcher no longer active
|
|
238
230
|
});
|
|
239
231
|
|
package/src/core/scope/scope.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
concat,
|
|
3
|
-
forEach,
|
|
4
3
|
minErr,
|
|
5
4
|
nextUid,
|
|
6
5
|
isFunction,
|
|
@@ -58,7 +57,7 @@ const $rootScopeMinErr = minErr("$rootScope");
|
|
|
58
57
|
|
|
59
58
|
/** @type {AsyncQueueTask[]} */
|
|
60
59
|
export const $$asyncQueue = [];
|
|
61
|
-
export const
|
|
60
|
+
export const $postUpdateQueue = [];
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
63
|
* @type {Function[]}
|
|
@@ -209,11 +208,6 @@ export class Scope {
|
|
|
209
208
|
/** @type {number} */
|
|
210
209
|
this.$$watchersCount = 0;
|
|
211
210
|
this.$$isolateBindings = null;
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* @type {?Scope}
|
|
215
|
-
*/
|
|
216
|
-
this.$$ChildScope = null;
|
|
217
211
|
}
|
|
218
212
|
|
|
219
213
|
/**
|
|
@@ -231,16 +225,11 @@ export class Scope {
|
|
|
231
225
|
* When creating widgets, it is useful for the widget to not accidentally read parent
|
|
232
226
|
* state.
|
|
233
227
|
*
|
|
234
|
-
* @param {?Scope} [parent=this] The {@link ng.$rootScope.Scope `Scope`} that will be the `$parent`
|
|
235
|
-
* of the newly created scope. Defaults to `this` scope if not provided.
|
|
236
|
-
* This is used when creating a transclude scope to correctly place it
|
|
237
|
-
* in the scope hierarchy while maintaining the correct prototypical
|
|
238
|
-
* inheritance.
|
|
239
228
|
*
|
|
240
229
|
* @returns {Scope} The newly created child scope.
|
|
241
230
|
*
|
|
242
231
|
*/
|
|
243
|
-
$new(isolate
|
|
232
|
+
$new(isolate) {
|
|
244
233
|
let child = isolate ? new Scope() : Object.create(this);
|
|
245
234
|
|
|
246
235
|
if (isolate) {
|
|
@@ -255,11 +244,10 @@ export class Scope {
|
|
|
255
244
|
child.$$listeners = new Map();
|
|
256
245
|
child.$$listenerCount = {};
|
|
257
246
|
child.$$watchersCount = 0;
|
|
258
|
-
child.$$ChildScope = null;
|
|
259
247
|
child.$$suspended = false;
|
|
260
248
|
}
|
|
261
249
|
|
|
262
|
-
child.$parent =
|
|
250
|
+
child.$parent = this;
|
|
263
251
|
child.$$prevSibling = child.$parent.$$childTail;
|
|
264
252
|
|
|
265
253
|
if (child.$parent.$$childHead) {
|
|
@@ -271,7 +259,7 @@ export class Scope {
|
|
|
271
259
|
}
|
|
272
260
|
|
|
273
261
|
// Add a destroy listener if isolated or the parent differs from `this`
|
|
274
|
-
if (isolate
|
|
262
|
+
if (isolate) {
|
|
275
263
|
child.$on("$destroy", ($event) => {
|
|
276
264
|
$event.currentScope.$$destroyed = true;
|
|
277
265
|
});
|
|
@@ -280,6 +268,49 @@ export class Scope {
|
|
|
280
268
|
return child;
|
|
281
269
|
}
|
|
282
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Creates a transcluded scope
|
|
273
|
+
* @param {Scope} parent The {@link ng.$rootScope.Scope `Scope`} that will be the `$parent`
|
|
274
|
+
* of the newly created scope. This is used when creating a transclude scope to correctly place it
|
|
275
|
+
* in the scope hierarchy while maintaining the correct prototypical inheritance.
|
|
276
|
+
*
|
|
277
|
+
* @returns {Scope} The newly created child scope.
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
280
|
+
$transcluded(parent) {
|
|
281
|
+
let child = Object.create(this);
|
|
282
|
+
|
|
283
|
+
// Initialize properties for a non-isolated child scope
|
|
284
|
+
child.$id = nextUid();
|
|
285
|
+
child.$$watchers = [];
|
|
286
|
+
child.$$nextSibling = null;
|
|
287
|
+
child.$$childHead = null;
|
|
288
|
+
child.$$childTail = null;
|
|
289
|
+
child.$$listeners = new Map();
|
|
290
|
+
child.$$listenerCount = {};
|
|
291
|
+
child.$$watchersCount = 0;
|
|
292
|
+
child.$$suspended = false;
|
|
293
|
+
|
|
294
|
+
child.$parent = parent || this;
|
|
295
|
+
child.$$prevSibling = child.$parent.$$childTail;
|
|
296
|
+
|
|
297
|
+
if (child.$parent.$$childHead) {
|
|
298
|
+
child.$parent.$$childTail.$$nextSibling = child;
|
|
299
|
+
child.$parent.$$childTail = child;
|
|
300
|
+
} else {
|
|
301
|
+
child.$parent.$$childHead = child;
|
|
302
|
+
child.$parent.$$childTail = child;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Add a destroy listener if isolated or the parent differs from `this`
|
|
306
|
+
if (parent !== this) {
|
|
307
|
+
child.$on("$destroy", ($event) => {
|
|
308
|
+
$event.currentScope.$$destroyed = true;
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return child;
|
|
313
|
+
}
|
|
283
314
|
/**
|
|
284
315
|
* Registers a `listener` callback to be executed whenever the `watchExpression` changes.
|
|
285
316
|
*
|
|
@@ -332,16 +363,16 @@ export class Scope {
|
|
|
332
363
|
});
|
|
333
364
|
expect(scope.counter).toEqual(0);
|
|
334
365
|
|
|
335
|
-
|
|
366
|
+
;
|
|
336
367
|
// the listener is always called during the first $digest loop after it was registered
|
|
337
368
|
expect(scope.counter).toEqual(1);
|
|
338
369
|
|
|
339
|
-
|
|
370
|
+
;
|
|
340
371
|
// but now it will not be called unless the value changes
|
|
341
372
|
expect(scope.counter).toEqual(1);
|
|
342
373
|
|
|
343
374
|
scope.name = 'adam';
|
|
344
|
-
|
|
375
|
+
;
|
|
345
376
|
expect(scope.counter).toEqual(2);
|
|
346
377
|
|
|
347
378
|
// Using a function as a watchExpression
|
|
@@ -363,12 +394,12 @@ export class Scope {
|
|
|
363
394
|
expect(scope.foodCounter).toEqual(0);
|
|
364
395
|
|
|
365
396
|
// Run the digest but since food has not changed count will still be zero
|
|
366
|
-
|
|
397
|
+
;
|
|
367
398
|
expect(scope.foodCounter).toEqual(0);
|
|
368
399
|
|
|
369
400
|
// Update food and run digest. Now the counter will increment
|
|
370
401
|
food = 'cheeseburger';
|
|
371
|
-
|
|
402
|
+
;
|
|
372
403
|
expect(scope.foodCounter).toEqual(1);
|
|
373
404
|
|
|
374
405
|
* ```
|
|
@@ -473,7 +504,7 @@ export class Scope {
|
|
|
473
504
|
});
|
|
474
505
|
}
|
|
475
506
|
|
|
476
|
-
forEach(
|
|
507
|
+
Object.entries(watchExpressions).forEach(([i, expr]) => {
|
|
477
508
|
const unwatchFn = self.$watch(expr, (value) => {
|
|
478
509
|
newValues[i] = value;
|
|
479
510
|
if (!changeReactionScheduled) {
|
|
@@ -675,7 +706,6 @@ export class Scope {
|
|
|
675
706
|
}
|
|
676
707
|
}
|
|
677
708
|
}
|
|
678
|
-
// TODO: fix this type signature
|
|
679
709
|
return this.$watch(changeDetector, $watchCollectionAction);
|
|
680
710
|
}
|
|
681
711
|
|
|
@@ -711,16 +741,16 @@ export class Scope {
|
|
|
711
741
|
});
|
|
712
742
|
expect(scope.counter).toEqual(0);
|
|
713
743
|
|
|
714
|
-
|
|
744
|
+
;
|
|
715
745
|
// the listener is always called during the first $digest loop after it was registered
|
|
716
746
|
expect(scope.counter).toEqual(1);
|
|
717
747
|
|
|
718
|
-
|
|
748
|
+
;
|
|
719
749
|
// but now it will not be called unless the value changes
|
|
720
750
|
expect(scope.counter).toEqual(1);
|
|
721
751
|
|
|
722
752
|
scope.name = 'adam';
|
|
723
|
-
|
|
753
|
+
;
|
|
724
754
|
expect(scope.counter).toEqual(2);
|
|
725
755
|
* ```
|
|
726
756
|
*
|
|
@@ -862,14 +892,14 @@ export class Scope {
|
|
|
862
892
|
this.clearPhase();
|
|
863
893
|
|
|
864
894
|
// postDigestQueuePosition isn't local here because this loop can be reentered recursively.
|
|
865
|
-
while (postDigestQueuePosition <
|
|
895
|
+
while (postDigestQueuePosition < $postUpdateQueue.length) {
|
|
866
896
|
try {
|
|
867
|
-
|
|
897
|
+
$postUpdateQueue[postDigestQueuePosition++]();
|
|
868
898
|
} catch (e) {
|
|
869
899
|
$exceptionHandler(e);
|
|
870
900
|
}
|
|
871
901
|
}
|
|
872
|
-
|
|
902
|
+
$postUpdateQueue.length = postDigestQueuePosition = 0;
|
|
873
903
|
|
|
874
904
|
// Check for changes to browser url that happened during the $digest
|
|
875
905
|
// (for which no event is fired; e.g. via `history.pushState()`)
|
|
@@ -906,7 +936,7 @@ export class Scope {
|
|
|
906
936
|
* Some of the things to consider are:
|
|
907
937
|
*
|
|
908
938
|
* * Any external event on a directive/component will not trigger a digest while the hosting
|
|
909
|
-
* scope is suspended - even if the event handler calls `$apply()` or
|
|
939
|
+
* scope is suspended - even if the event handler calls `$apply()` or ``.
|
|
910
940
|
* * Transcluded content exists on a scope that inherits from outside a directive but exists
|
|
911
941
|
* as a child of the directive's containing scope. If the containing scope is suspended the
|
|
912
942
|
* transcluded scope will also be suspended, even if the scope from which the transcluded
|
|
@@ -1120,8 +1150,8 @@ export class Scope {
|
|
|
1120
1150
|
return id;
|
|
1121
1151
|
}
|
|
1122
1152
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1153
|
+
$postUpdate(fn) {
|
|
1154
|
+
$postUpdateQueue.push(fn);
|
|
1125
1155
|
}
|
|
1126
1156
|
|
|
1127
1157
|
/**
|