@angular-wave/angular.ts 0.4.3 → 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.umd.js +10 -0
- package/index.html +74 -3
- package/package.json +1 -1
- package/src/angular.spec.js +0 -5
- package/src/animations/animate-css.js +5 -13
- package/src/animations/animate-queue.js +22 -21
- 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 +1 -1
- package/src/binding.spec.js +0 -1
- package/src/core/cache/cache.js +2 -29
- package/src/core/compile/compile.js +26 -27
- package/src/core/compile/compile.spec.js +17 -266
- 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/interval/interval.test.js +1 -1
- 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 +26 -5
- package/src/core/parse/parse.spec.js +95 -91
- package/src/core/prop.spec.js +4 -60
- package/src/core/sce/sce.spec.js +0 -8
- package/src/core/scope/scope.js +61 -30
- 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/attrs/boolean.spec.js +0 -15
- package/src/directive/attrs/element-style.spec.js +0 -8
- 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 +0 -3
- package/src/{core/q/q.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/{list/list.test.js → channel/channel.test.js} +2 -4
- 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 +2 -3
- package/src/directive/form/form.spec.js +0 -65
- package/src/directive/if/if.spec.js +0 -4
- 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.spec.js +0 -136
- package/src/directive/messages/messages.spec.js +4 -35
- package/src/directive/model/model.js +18 -25
- package/src/directive/model/model.spec.js +2 -49
- 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.spec.js +0 -34
- package/src/directive/ref/href.spec.js +0 -15
- package/src/directive/repeat/repeat.spec.js +8 -135
- package/src/directive/script/script.spec.js +0 -2
- package/src/directive/select/select.js +3 -3
- package/src/directive/select/select.spec.js +0 -96
- 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.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 +6 -14
- package/src/router/directives/state-directives.spec.js +0 -83
- package/src/router/directives/view-directive.js +4 -13
- 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 +7 -10
- 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/view-hook.spec.js +2 -2
- package/src/router/view-scroll.js +4 -6
- package/src/services/http/http.js +6 -9
- 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.spec.js +3 -3
- package/src/services/template-request.js +2 -4
- package/src/shared/common.js +1 -2
- package/src/shared/jqlite/jqlite.js +0 -3
- 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/src/core/interval/interval-factory.js +0 -50
- package/src/core/interval/interval.html +0 -18
- 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/q/q.test.js +0 -12
- package/src/core/scope/scope.test.js +0 -12
- package/src/core/timeout/timeout.html +0 -18
- 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.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
|
@@ -57,7 +57,7 @@ const $rootScopeMinErr = minErr("$rootScope");
|
|
|
57
57
|
|
|
58
58
|
/** @type {AsyncQueueTask[]} */
|
|
59
59
|
export const $$asyncQueue = [];
|
|
60
|
-
export const
|
|
60
|
+
export const $postUpdateQueue = [];
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* @type {Function[]}
|
|
@@ -208,11 +208,6 @@ export class Scope {
|
|
|
208
208
|
/** @type {number} */
|
|
209
209
|
this.$$watchersCount = 0;
|
|
210
210
|
this.$$isolateBindings = null;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* @type {?Scope}
|
|
214
|
-
*/
|
|
215
|
-
this.$$ChildScope = null;
|
|
216
211
|
}
|
|
217
212
|
|
|
218
213
|
/**
|
|
@@ -230,16 +225,11 @@ export class Scope {
|
|
|
230
225
|
* When creating widgets, it is useful for the widget to not accidentally read parent
|
|
231
226
|
* state.
|
|
232
227
|
*
|
|
233
|
-
* @param {?Scope} [parent=this] The {@link ng.$rootScope.Scope `Scope`} that will be the `$parent`
|
|
234
|
-
* of the newly created scope. Defaults to `this` scope if not provided.
|
|
235
|
-
* This is used when creating a transclude scope to correctly place it
|
|
236
|
-
* in the scope hierarchy while maintaining the correct prototypical
|
|
237
|
-
* inheritance.
|
|
238
228
|
*
|
|
239
229
|
* @returns {Scope} The newly created child scope.
|
|
240
230
|
*
|
|
241
231
|
*/
|
|
242
|
-
$new(isolate
|
|
232
|
+
$new(isolate) {
|
|
243
233
|
let child = isolate ? new Scope() : Object.create(this);
|
|
244
234
|
|
|
245
235
|
if (isolate) {
|
|
@@ -254,11 +244,10 @@ export class Scope {
|
|
|
254
244
|
child.$$listeners = new Map();
|
|
255
245
|
child.$$listenerCount = {};
|
|
256
246
|
child.$$watchersCount = 0;
|
|
257
|
-
child.$$ChildScope = null;
|
|
258
247
|
child.$$suspended = false;
|
|
259
248
|
}
|
|
260
249
|
|
|
261
|
-
child.$parent =
|
|
250
|
+
child.$parent = this;
|
|
262
251
|
child.$$prevSibling = child.$parent.$$childTail;
|
|
263
252
|
|
|
264
253
|
if (child.$parent.$$childHead) {
|
|
@@ -270,7 +259,7 @@ export class Scope {
|
|
|
270
259
|
}
|
|
271
260
|
|
|
272
261
|
// Add a destroy listener if isolated or the parent differs from `this`
|
|
273
|
-
if (isolate
|
|
262
|
+
if (isolate) {
|
|
274
263
|
child.$on("$destroy", ($event) => {
|
|
275
264
|
$event.currentScope.$$destroyed = true;
|
|
276
265
|
});
|
|
@@ -279,6 +268,49 @@ export class Scope {
|
|
|
279
268
|
return child;
|
|
280
269
|
}
|
|
281
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
|
+
}
|
|
282
314
|
/**
|
|
283
315
|
* Registers a `listener` callback to be executed whenever the `watchExpression` changes.
|
|
284
316
|
*
|
|
@@ -331,16 +363,16 @@ export class Scope {
|
|
|
331
363
|
});
|
|
332
364
|
expect(scope.counter).toEqual(0);
|
|
333
365
|
|
|
334
|
-
|
|
366
|
+
;
|
|
335
367
|
// the listener is always called during the first $digest loop after it was registered
|
|
336
368
|
expect(scope.counter).toEqual(1);
|
|
337
369
|
|
|
338
|
-
|
|
370
|
+
;
|
|
339
371
|
// but now it will not be called unless the value changes
|
|
340
372
|
expect(scope.counter).toEqual(1);
|
|
341
373
|
|
|
342
374
|
scope.name = 'adam';
|
|
343
|
-
|
|
375
|
+
;
|
|
344
376
|
expect(scope.counter).toEqual(2);
|
|
345
377
|
|
|
346
378
|
// Using a function as a watchExpression
|
|
@@ -362,12 +394,12 @@ export class Scope {
|
|
|
362
394
|
expect(scope.foodCounter).toEqual(0);
|
|
363
395
|
|
|
364
396
|
// Run the digest but since food has not changed count will still be zero
|
|
365
|
-
|
|
397
|
+
;
|
|
366
398
|
expect(scope.foodCounter).toEqual(0);
|
|
367
399
|
|
|
368
400
|
// Update food and run digest. Now the counter will increment
|
|
369
401
|
food = 'cheeseburger';
|
|
370
|
-
|
|
402
|
+
;
|
|
371
403
|
expect(scope.foodCounter).toEqual(1);
|
|
372
404
|
|
|
373
405
|
* ```
|
|
@@ -674,7 +706,6 @@ export class Scope {
|
|
|
674
706
|
}
|
|
675
707
|
}
|
|
676
708
|
}
|
|
677
|
-
// TODO: fix this type signature
|
|
678
709
|
return this.$watch(changeDetector, $watchCollectionAction);
|
|
679
710
|
}
|
|
680
711
|
|
|
@@ -710,16 +741,16 @@ export class Scope {
|
|
|
710
741
|
});
|
|
711
742
|
expect(scope.counter).toEqual(0);
|
|
712
743
|
|
|
713
|
-
|
|
744
|
+
;
|
|
714
745
|
// the listener is always called during the first $digest loop after it was registered
|
|
715
746
|
expect(scope.counter).toEqual(1);
|
|
716
747
|
|
|
717
|
-
|
|
748
|
+
;
|
|
718
749
|
// but now it will not be called unless the value changes
|
|
719
750
|
expect(scope.counter).toEqual(1);
|
|
720
751
|
|
|
721
752
|
scope.name = 'adam';
|
|
722
|
-
|
|
753
|
+
;
|
|
723
754
|
expect(scope.counter).toEqual(2);
|
|
724
755
|
* ```
|
|
725
756
|
*
|
|
@@ -861,14 +892,14 @@ export class Scope {
|
|
|
861
892
|
this.clearPhase();
|
|
862
893
|
|
|
863
894
|
// postDigestQueuePosition isn't local here because this loop can be reentered recursively.
|
|
864
|
-
while (postDigestQueuePosition <
|
|
895
|
+
while (postDigestQueuePosition < $postUpdateQueue.length) {
|
|
865
896
|
try {
|
|
866
|
-
|
|
897
|
+
$postUpdateQueue[postDigestQueuePosition++]();
|
|
867
898
|
} catch (e) {
|
|
868
899
|
$exceptionHandler(e);
|
|
869
900
|
}
|
|
870
901
|
}
|
|
871
|
-
|
|
902
|
+
$postUpdateQueue.length = postDigestQueuePosition = 0;
|
|
872
903
|
|
|
873
904
|
// Check for changes to browser url that happened during the $digest
|
|
874
905
|
// (for which no event is fired; e.g. via `history.pushState()`)
|
|
@@ -905,7 +936,7 @@ export class Scope {
|
|
|
905
936
|
* Some of the things to consider are:
|
|
906
937
|
*
|
|
907
938
|
* * Any external event on a directive/component will not trigger a digest while the hosting
|
|
908
|
-
* scope is suspended - even if the event handler calls `$apply()` or
|
|
939
|
+
* scope is suspended - even if the event handler calls `$apply()` or ``.
|
|
909
940
|
* * Transcluded content exists on a scope that inherits from outside a directive but exists
|
|
910
941
|
* as a child of the directive's containing scope. If the containing scope is suspended the
|
|
911
942
|
* transcluded scope will also be suspended, even if the scope from which the transcluded
|
|
@@ -1119,8 +1150,8 @@ export class Scope {
|
|
|
1119
1150
|
return id;
|
|
1120
1151
|
}
|
|
1121
1152
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1153
|
+
$postUpdate(fn) {
|
|
1154
|
+
$postUpdateQueue.push(fn);
|
|
1124
1155
|
}
|
|
1125
1156
|
|
|
1126
1157
|
/**
|