@angular-wave/angular.ts 0.0.6 → 0.0.8
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.cjs.js +1 -1
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/docs/.cspell.yml +8 -0
- package/docs/.github/dependabot.yml +14 -0
- package/docs/.nvmrc +1 -0
- package/docs/CONTRIBUTING.md +28 -0
- package/docs/Dockerfile +4 -0
- package/docs/LICENSE +201 -0
- package/docs/README.md +184 -0
- package/docs/assets/scss/_variables_project.scss +6 -0
- package/docs/config.yaml +15 -0
- package/docs/content/en/_index.md +77 -0
- package/docs/content/en/about/featured-background.jpg +0 -0
- package/docs/content/en/about/index.md +35 -0
- package/docs/content/en/blog/_index.md +8 -0
- package/docs/content/en/blog/news/_index.md +4 -0
- package/docs/content/en/blog/news/first-post/featured-sunset-get.png +0 -0
- package/docs/content/en/blog/news/first-post/index.md +48 -0
- package/docs/content/en/blog/news/second-post.md +244 -0
- package/docs/content/en/blog/releases/_index.md +4 -0
- package/docs/content/en/blog/releases/in-depth-monoliths-detailed-spec.md +244 -0
- package/docs/content/en/community/_index.md +6 -0
- package/docs/content/en/docs/_index.md +29 -0
- package/docs/content/en/docs/concepts/_index.md +14 -0
- package/docs/content/en/docs/contribution-guidelines/_index.md +79 -0
- package/docs/content/en/docs/examples/_index.md +13 -0
- package/docs/content/en/docs/getting-started/_index.md +35 -0
- package/docs/content/en/docs/getting-started/example-page.md +240 -0
- package/docs/content/en/docs/overview/_index.md +36 -0
- package/docs/content/en/docs/reference/_index.md +12 -0
- package/docs/content/en/docs/reference/parameter-reference.md +211 -0
- package/docs/content/en/docs/tasks/Ponycopters/_index.md +12 -0
- package/docs/content/en/docs/tasks/Ponycopters/configuring-ponycopters.md +238 -0
- package/docs/content/en/docs/tasks/Ponycopters/launching-ponycopters.md +236 -0
- package/docs/content/en/docs/tasks/_index.md +21 -0
- package/docs/content/en/docs/tasks/beds.md +237 -0
- package/docs/content/en/docs/tasks/porridge.md +237 -0
- package/docs/content/en/docs/tasks/task.md +237 -0
- package/docs/content/en/docs/tutorials/_index.md +13 -0
- package/docs/content/en/docs/tutorials/multi-bear.md +236 -0
- package/docs/content/en/docs/tutorials/tutorial2.md +236 -0
- package/docs/content/en/featured-background.jpg +0 -0
- package/docs/content/en/search.md +4 -0
- package/docs/docker-compose.yaml +13 -0
- package/docs/docsy.work +5 -0
- package/docs/docsy.work.sum +0 -0
- package/docs/go.mod +5 -0
- package/docs/go.sum +6 -0
- package/docs/hugo-disabled.toml +221 -0
- package/docs/hugo.yaml +220 -0
- package/docs/layouts/404.html +7 -0
- package/docs/layouts/_default/_markup/render-heading.html +1 -0
- package/docs/netlify.toml +12 -0
- package/docs/package.json +42 -0
- package/package.json +1 -1
- package/src/core/compile.js +15 -168
- package/src/core/compile.md +51 -16
- package/src/core/filter.js +0 -110
- package/src/core/filter.md +132 -0
- package/src/core/interval.js +0 -126
- package/src/core/interval.md +123 -0
- package/src/core/location.js +1 -2
- package/src/core/sce.js +2 -13
- package/src/injector.js +0 -630
- package/src/injector.md +740 -0
- package/src/jqLite.js +1 -1
- package/src/loader.js +1 -15
- package/src/loader.md +13 -0
- package/test/jqlite.spec.js +4 -4
- package/test/messages/messages.spec.js +1 -1
- package/test/ng/compile.spec.js +118 -316
- package/test/ng/directive/form.spec.js +8 -8
- package/src/route-to-reg-exp.js +0 -41
package/test/ng/compile.spec.js
CHANGED
|
@@ -89,7 +89,7 @@ describe("$compile", () => {
|
|
|
89
89
|
function registerDefaultDirectives() {
|
|
90
90
|
return registerDirectives({
|
|
91
91
|
log: () => ({
|
|
92
|
-
restrict: "
|
|
92
|
+
restrict: "A",
|
|
93
93
|
priority: 0,
|
|
94
94
|
compile: valueFn((scope, element, attrs) => {
|
|
95
95
|
log.push(attrs.log || "LOG");
|
|
@@ -97,7 +97,7 @@ describe("$compile", () => {
|
|
|
97
97
|
}),
|
|
98
98
|
|
|
99
99
|
highLog: () => ({
|
|
100
|
-
restrict: "
|
|
100
|
+
restrict: "A",
|
|
101
101
|
priority: 3,
|
|
102
102
|
compile: valueFn((scope, element, attrs) => {
|
|
103
103
|
log.push(attrs.highLog || "HIGH");
|
|
@@ -105,7 +105,7 @@ describe("$compile", () => {
|
|
|
105
105
|
}),
|
|
106
106
|
|
|
107
107
|
mediumLog: () => ({
|
|
108
|
-
restrict: "
|
|
108
|
+
restrict: "A",
|
|
109
109
|
priority: 2,
|
|
110
110
|
compile: valueFn((scope, element, attrs) => {
|
|
111
111
|
log.push(attrs.mediumLog || "MEDIUM");
|
|
@@ -113,7 +113,7 @@ describe("$compile", () => {
|
|
|
113
113
|
}),
|
|
114
114
|
|
|
115
115
|
greet: () => ({
|
|
116
|
-
restrict: "
|
|
116
|
+
restrict: "A",
|
|
117
117
|
priority: 10,
|
|
118
118
|
compile: valueFn((scope, element, attrs) => {
|
|
119
119
|
element.text(`Hello ${attrs.greet}`);
|
|
@@ -732,21 +732,12 @@ describe("$compile", () => {
|
|
|
732
732
|
expect(element.text()).toEqual("0hello2angular4");
|
|
733
733
|
});
|
|
734
734
|
|
|
735
|
-
it("should allow directives in classes", () => {
|
|
736
|
-
reloadModules();
|
|
737
|
-
element = $compile('<div class="greet: angular; log:123;"></div>')(
|
|
738
|
-
$rootScope,
|
|
739
|
-
);
|
|
740
|
-
expect(element.html()).toEqual("Hello angular");
|
|
741
|
-
expect(log[0]).toEqual("123");
|
|
742
|
-
});
|
|
743
|
-
|
|
744
735
|
it("should allow directives in SVG element classes", () => {
|
|
745
736
|
reloadModules();
|
|
746
737
|
if (!window.SVGElement) return;
|
|
747
|
-
element = $compile(
|
|
748
|
-
|
|
749
|
-
)
|
|
738
|
+
element = $compile('<svg><text greet="angular" log="123"></text></svg>')(
|
|
739
|
+
$rootScope,
|
|
740
|
+
);
|
|
750
741
|
const text = element.children().eq(0);
|
|
751
742
|
// In old Safari, SVG elements don't have innerHTML, so element.html() won't work
|
|
752
743
|
// (https://bugs.webkit.org/show_bug.cgi?id=136903)
|
|
@@ -769,7 +760,7 @@ describe("$compile", () => {
|
|
|
769
760
|
myModule.directive("log", ($rootScope, $injector) => {
|
|
770
761
|
injectableInjector = $injector;
|
|
771
762
|
return {
|
|
772
|
-
restrict: "
|
|
763
|
+
restrict: "A",
|
|
773
764
|
compile(element, templateAttr) {
|
|
774
765
|
expect(typeof templateAttr.$normalize).toBe("function");
|
|
775
766
|
expect(typeof templateAttr.$set).toBe("function");
|
|
@@ -791,7 +782,7 @@ describe("$compile", () => {
|
|
|
791
782
|
|
|
792
783
|
reloadModules();
|
|
793
784
|
element = $compile(
|
|
794
|
-
'<div
|
|
785
|
+
'<div log exp="abc" aa="A" x-Bb="B" daTa-cC="C">unlinked</div>',
|
|
795
786
|
)($rootScope);
|
|
796
787
|
|
|
797
788
|
expect(element.text()).toEqual("worked");
|
|
@@ -4675,31 +4666,9 @@ describe("$compile", () => {
|
|
|
4675
4666
|
]);
|
|
4676
4667
|
});
|
|
4677
4668
|
|
|
4678
|
-
it("should allow commentDirectivesEnabled to be configured", () => {
|
|
4679
|
-
createInjector([
|
|
4680
|
-
"ng",
|
|
4681
|
-
($compileProvider) => {
|
|
4682
|
-
expect($compileProvider.commentDirectivesEnabled()).toBe(true); // the default
|
|
4683
|
-
$compileProvider.commentDirectivesEnabled(false);
|
|
4684
|
-
expect($compileProvider.commentDirectivesEnabled()).toBe(false);
|
|
4685
|
-
},
|
|
4686
|
-
]);
|
|
4687
|
-
});
|
|
4688
|
-
|
|
4689
|
-
it("should allow cssClassDirectivesEnabled to be configured", () => {
|
|
4690
|
-
createInjector([
|
|
4691
|
-
"ng",
|
|
4692
|
-
($compileProvider) => {
|
|
4693
|
-
expect($compileProvider.cssClassDirectivesEnabled()).toBe(true); // the default
|
|
4694
|
-
$compileProvider.cssClassDirectivesEnabled(false);
|
|
4695
|
-
expect($compileProvider.cssClassDirectivesEnabled()).toBe(false);
|
|
4696
|
-
},
|
|
4697
|
-
]);
|
|
4698
|
-
});
|
|
4699
|
-
|
|
4700
4669
|
it("should register a directive", () => {
|
|
4701
4670
|
myModule.directive("div", () => ({
|
|
4702
|
-
restrict: "
|
|
4671
|
+
restrict: "EA",
|
|
4703
4672
|
link(scope, element) {
|
|
4704
4673
|
log = "OK";
|
|
4705
4674
|
element.text("SUCCESS");
|
|
@@ -4714,14 +4683,14 @@ describe("$compile", () => {
|
|
|
4714
4683
|
it("should allow registration of multiple directives with same name", () => {
|
|
4715
4684
|
myModule
|
|
4716
4685
|
.directive("div", () => ({
|
|
4717
|
-
restrict: "
|
|
4686
|
+
restrict: "EA",
|
|
4718
4687
|
link: {
|
|
4719
4688
|
pre: () => log.push("pre1"),
|
|
4720
4689
|
post: () => log.push("post1"),
|
|
4721
4690
|
},
|
|
4722
4691
|
}))
|
|
4723
4692
|
.directive("div", () => ({
|
|
4724
|
-
restrict: "
|
|
4693
|
+
restrict: "EA",
|
|
4725
4694
|
link: {
|
|
4726
4695
|
pre: () => log.push("pre2"),
|
|
4727
4696
|
post: () => log.push("post2"),
|
|
@@ -5081,36 +5050,36 @@ describe("$compile", () => {
|
|
|
5081
5050
|
// We compile the contents of element (i.e. not element itself)
|
|
5082
5051
|
// Then delete these contents and check the cache has been reset to zero
|
|
5083
5052
|
// Clear cache
|
|
5084
|
-
|
|
5053
|
+
CACHE.clear();
|
|
5085
5054
|
window.angular.module("test1", ["ng"]);
|
|
5086
5055
|
createInjector(["test1"]).invoke(($compile) => {
|
|
5087
|
-
expect(
|
|
5056
|
+
expect(CACHE.size).toEqual(1);
|
|
5088
5057
|
// First with only elements at the top level
|
|
5089
5058
|
element = JQLite("<div><div></div></div>");
|
|
5090
5059
|
$compile(element[0].childNodes)($rootScope);
|
|
5091
|
-
expect(
|
|
5060
|
+
expect(CACHE.size).toEqual(2);
|
|
5092
5061
|
element.empty();
|
|
5093
|
-
expect(
|
|
5062
|
+
expect(CACHE.size).toEqual(1);
|
|
5094
5063
|
|
|
5095
5064
|
// Next with non-empty text nodes at the top level
|
|
5096
5065
|
// (in this case the compiler will wrap them in a <span>)
|
|
5097
5066
|
element = JQLite("<div>xxx</div>");
|
|
5098
5067
|
$compile(element[0].childNodes)($rootScope);
|
|
5099
5068
|
element.empty();
|
|
5100
|
-
expect(
|
|
5069
|
+
expect(CACHE.size).toEqual(1);
|
|
5101
5070
|
|
|
5102
5071
|
// Next with comment nodes at the top level
|
|
5103
5072
|
element = JQLite("<div><!-- comment --></div>");
|
|
5104
5073
|
$compile(element[0].childNodes)($rootScope);
|
|
5105
5074
|
element.empty();
|
|
5106
|
-
expect(
|
|
5075
|
+
expect(CACHE.size).toEqual(1);
|
|
5107
5076
|
|
|
5108
5077
|
// Finally with empty text nodes at the top level
|
|
5109
5078
|
element = JQLite("<div> \n<div></div> </div>");
|
|
5110
5079
|
$compile(element[0].childNodes)($rootScope);
|
|
5111
|
-
expect(
|
|
5080
|
+
expect(CACHE.size).toEqual(2);
|
|
5112
5081
|
element.empty();
|
|
5113
|
-
expect(
|
|
5082
|
+
expect(CACHE.size).toEqual(1);
|
|
5114
5083
|
});
|
|
5115
5084
|
});
|
|
5116
5085
|
|
|
@@ -5272,7 +5241,7 @@ describe("$compile", () => {
|
|
|
5272
5241
|
reloadModules();
|
|
5273
5242
|
|
|
5274
5243
|
element = $compile(
|
|
5275
|
-
'<div high-log medium-stop log
|
|
5244
|
+
'<div high-log medium-stop log medium-log><a set="FAIL">OK</a></div>',
|
|
5276
5245
|
)($rootScope);
|
|
5277
5246
|
expect(element.text()).toEqual("OK");
|
|
5278
5247
|
expect(log).toEqual(["MEDIUM", "HIGH"]);
|
|
@@ -5334,7 +5303,7 @@ describe("$compile", () => {
|
|
|
5334
5303
|
.directive(
|
|
5335
5304
|
"replace",
|
|
5336
5305
|
valueFn({
|
|
5337
|
-
restrict: "
|
|
5306
|
+
restrict: "A",
|
|
5338
5307
|
replace: true,
|
|
5339
5308
|
template:
|
|
5340
5309
|
'<div class="log" style="width: 10px" high-log>Replace!</div>',
|
|
@@ -5347,7 +5316,7 @@ describe("$compile", () => {
|
|
|
5347
5316
|
.directive(
|
|
5348
5317
|
"nomerge",
|
|
5349
5318
|
valueFn({
|
|
5350
|
-
restrict: "
|
|
5319
|
+
restrict: "A",
|
|
5351
5320
|
replace: true,
|
|
5352
5321
|
template: '<div class="log" id="myid" high-log>No Merge!</div>',
|
|
5353
5322
|
compile(element, attr) {
|
|
@@ -5359,7 +5328,7 @@ describe("$compile", () => {
|
|
|
5359
5328
|
.directive(
|
|
5360
5329
|
"append",
|
|
5361
5330
|
valueFn({
|
|
5362
|
-
restrict: "
|
|
5331
|
+
restrict: "A",
|
|
5363
5332
|
template:
|
|
5364
5333
|
'<div class="log" style="width: 10px" high-log>Append!</div>',
|
|
5365
5334
|
compile(element, attr) {
|
|
@@ -5873,7 +5842,7 @@ describe("$compile", () => {
|
|
|
5873
5842
|
.directive(
|
|
5874
5843
|
"hello",
|
|
5875
5844
|
valueFn({
|
|
5876
|
-
restrict: "
|
|
5845
|
+
restrict: "A",
|
|
5877
5846
|
templateUrl: "mock/hello",
|
|
5878
5847
|
transclude: true,
|
|
5879
5848
|
}),
|
|
@@ -5881,7 +5850,7 @@ describe("$compile", () => {
|
|
|
5881
5850
|
.directive(
|
|
5882
5851
|
"401",
|
|
5883
5852
|
valueFn({
|
|
5884
|
-
restrict: "
|
|
5853
|
+
restrict: "A",
|
|
5885
5854
|
templateUrl: "mock/401",
|
|
5886
5855
|
transclude: true,
|
|
5887
5856
|
}),
|
|
@@ -5889,19 +5858,19 @@ describe("$compile", () => {
|
|
|
5889
5858
|
.directive(
|
|
5890
5859
|
"cau",
|
|
5891
5860
|
valueFn({
|
|
5892
|
-
restrict: "
|
|
5861
|
+
restrict: "A",
|
|
5893
5862
|
templateUrl: "mock/divexpr",
|
|
5894
5863
|
}),
|
|
5895
5864
|
)
|
|
5896
5865
|
.directive(
|
|
5897
5866
|
"crossDomainTemplate",
|
|
5898
5867
|
valueFn({
|
|
5899
|
-
restrict: "
|
|
5868
|
+
restrict: "A",
|
|
5900
5869
|
templateUrl: "http://example.com/should-not-load.html",
|
|
5901
5870
|
}),
|
|
5902
5871
|
)
|
|
5903
5872
|
.directive("trustedTemplate", () => ({
|
|
5904
|
-
restrict: "
|
|
5873
|
+
restrict: "A",
|
|
5905
5874
|
templateUrl() {
|
|
5906
5875
|
return $sce.trustAsResourceUrl("http://localhost:3000/hello");
|
|
5907
5876
|
},
|
|
@@ -5909,7 +5878,7 @@ describe("$compile", () => {
|
|
|
5909
5878
|
.directive(
|
|
5910
5879
|
"cError",
|
|
5911
5880
|
valueFn({
|
|
5912
|
-
restrict: "
|
|
5881
|
+
restrict: "A",
|
|
5913
5882
|
templateUrl: "mock/empty",
|
|
5914
5883
|
compile() {
|
|
5915
5884
|
throw new Error("cError");
|
|
@@ -5919,7 +5888,7 @@ describe("$compile", () => {
|
|
|
5919
5888
|
.directive(
|
|
5920
5889
|
"lError",
|
|
5921
5890
|
valueFn({
|
|
5922
|
-
restrict: "
|
|
5891
|
+
restrict: "A",
|
|
5923
5892
|
templateUrl: "mock/empty",
|
|
5924
5893
|
compile() {
|
|
5925
5894
|
throw new Error("lError");
|
|
@@ -5929,7 +5898,7 @@ describe("$compile", () => {
|
|
|
5929
5898
|
.directive(
|
|
5930
5899
|
"iHello",
|
|
5931
5900
|
valueFn({
|
|
5932
|
-
restrict: "
|
|
5901
|
+
restrict: "A",
|
|
5933
5902
|
replace: true,
|
|
5934
5903
|
templateUrl: "mock/div",
|
|
5935
5904
|
}),
|
|
@@ -5937,7 +5906,7 @@ describe("$compile", () => {
|
|
|
5937
5906
|
.directive(
|
|
5938
5907
|
"iCau",
|
|
5939
5908
|
valueFn({
|
|
5940
|
-
restrict: "
|
|
5909
|
+
restrict: "A",
|
|
5941
5910
|
replace: true,
|
|
5942
5911
|
templateUrl: "mock/divexpr",
|
|
5943
5912
|
}),
|
|
@@ -5945,7 +5914,7 @@ describe("$compile", () => {
|
|
|
5945
5914
|
.directive(
|
|
5946
5915
|
"iCError",
|
|
5947
5916
|
valueFn({
|
|
5948
|
-
restrict: "
|
|
5917
|
+
restrict: "A",
|
|
5949
5918
|
replace: true,
|
|
5950
5919
|
templateUrl: "error.html",
|
|
5951
5920
|
compile() {
|
|
@@ -5956,7 +5925,7 @@ describe("$compile", () => {
|
|
|
5956
5925
|
.directive(
|
|
5957
5926
|
"iLError",
|
|
5958
5927
|
valueFn({
|
|
5959
|
-
restrict: "
|
|
5928
|
+
restrict: "A",
|
|
5960
5929
|
replace: true,
|
|
5961
5930
|
templateUrl: "error.html",
|
|
5962
5931
|
compile() {
|
|
@@ -6040,7 +6009,7 @@ describe("$compile", () => {
|
|
|
6040
6009
|
|
|
6041
6010
|
it("should not load cross domain templates by default", () => {
|
|
6042
6011
|
expect(() => {
|
|
6043
|
-
$compile(
|
|
6012
|
+
$compile("<div cross-domain-template></div>")($rootScope);
|
|
6044
6013
|
}).toThrowError(/insecurl/);
|
|
6045
6014
|
});
|
|
6046
6015
|
|
|
@@ -6049,27 +6018,23 @@ describe("$compile", () => {
|
|
|
6049
6018
|
"http://example.com/should-not-load.html",
|
|
6050
6019
|
"<span>example.com/cached-version</span>",
|
|
6051
6020
|
);
|
|
6052
|
-
element = $compile(
|
|
6053
|
-
$rootScope,
|
|
6054
|
-
);
|
|
6021
|
+
element = $compile("<div cross-domain-template></div>")($rootScope);
|
|
6055
6022
|
expect(element[0].outerHTML).toEqual(
|
|
6056
|
-
'<div
|
|
6023
|
+
'<div cross-domain-template=""></div>',
|
|
6057
6024
|
);
|
|
6058
6025
|
$rootScope.$digest();
|
|
6059
6026
|
expect(element[0].outerHTML).toEqual(
|
|
6060
|
-
'<div
|
|
6027
|
+
'<div cross-domain-template=""><span>example.com/cached-version</span></div>',
|
|
6061
6028
|
);
|
|
6062
6029
|
});
|
|
6063
6030
|
|
|
6064
6031
|
it("should load cross domain templates when trusted", (done) => {
|
|
6065
|
-
element = $compile(
|
|
6066
|
-
expect(element[0].outerHTML).toEqual(
|
|
6067
|
-
'<div class="trustedTemplate"></div>',
|
|
6068
|
-
);
|
|
6032
|
+
element = $compile("<div trusted-template></div>")($rootScope);
|
|
6033
|
+
expect(element[0].outerHTML).toEqual('<div trusted-template=""></div>');
|
|
6069
6034
|
$rootScope.$digest();
|
|
6070
6035
|
setTimeout(() => {
|
|
6071
6036
|
expect(element[0].outerHTML).toEqual(
|
|
6072
|
-
'<div
|
|
6037
|
+
'<div trusted-template="">Hello</div>',
|
|
6073
6038
|
);
|
|
6074
6039
|
done();
|
|
6075
6040
|
}, 100);
|
|
@@ -6077,22 +6042,22 @@ describe("$compile", () => {
|
|
|
6077
6042
|
|
|
6078
6043
|
it("should append template via $http and cache it in $templateCache", (done) => {
|
|
6079
6044
|
$templateCache.put("mock/divexpr", "<span>Cau!</span>");
|
|
6080
|
-
element = $compile(
|
|
6081
|
-
|
|
6082
|
-
)
|
|
6045
|
+
element = $compile("<div><b hello>ignore</b><b cau>ignore</b></div>")(
|
|
6046
|
+
$rootScope,
|
|
6047
|
+
);
|
|
6083
6048
|
expect(element[0].outerHTML).toEqual(
|
|
6084
|
-
'<div><b
|
|
6049
|
+
'<div><b hello=""></b><b cau=""></b></div>',
|
|
6085
6050
|
);
|
|
6086
6051
|
|
|
6087
6052
|
$rootScope.$digest();
|
|
6088
6053
|
|
|
6089
6054
|
expect(element[0].outerHTML).toEqual(
|
|
6090
|
-
'<div><b
|
|
6055
|
+
'<div><b hello=""></b><b cau=""><span>Cau!</span></b></div>',
|
|
6091
6056
|
);
|
|
6092
6057
|
|
|
6093
6058
|
setTimeout(() => {
|
|
6094
6059
|
expect(element[0].outerHTML).toEqual(
|
|
6095
|
-
`<div><b
|
|
6060
|
+
`<div><b hello="">Hello</b><b cau=""><span>Cau!</span></b></div>`,
|
|
6096
6061
|
);
|
|
6097
6062
|
done();
|
|
6098
6063
|
}, 100);
|
|
@@ -6101,21 +6066,21 @@ describe("$compile", () => {
|
|
|
6101
6066
|
it("should inline template via $http and cache it in $templateCache", (done) => {
|
|
6102
6067
|
$templateCache.put("mock/divexpr", "<span>Cau!</span>");
|
|
6103
6068
|
element = $compile(
|
|
6104
|
-
"<div><b
|
|
6069
|
+
"<div><b i-hello>ignore</b><b i-cau>ignore</b></div>",
|
|
6105
6070
|
)($rootScope);
|
|
6106
6071
|
expect(element[0].outerHTML).toEqual(
|
|
6107
|
-
'<div><b
|
|
6072
|
+
'<div><b i-hello=""></b><b i-cau=""></b></div>',
|
|
6108
6073
|
);
|
|
6109
6074
|
|
|
6110
6075
|
$rootScope.$digest();
|
|
6111
6076
|
|
|
6112
6077
|
expect(element[0].outerHTML).toBe(
|
|
6113
|
-
'<div><b
|
|
6078
|
+
'<div><b i-hello=""></b><span i-cau="">Cau!</span></div>',
|
|
6114
6079
|
);
|
|
6115
6080
|
|
|
6116
6081
|
setTimeout(() => {
|
|
6117
6082
|
expect(element[0].outerHTML).toBe(
|
|
6118
|
-
'<div><div
|
|
6083
|
+
'<div><div i-hello="">Hello</div><span i-cau="">Cau!</span></div>',
|
|
6119
6084
|
);
|
|
6120
6085
|
done();
|
|
6121
6086
|
}, 100);
|
|
@@ -6124,13 +6089,13 @@ describe("$compile", () => {
|
|
|
6124
6089
|
it("should compile, link and flush the template append", (done) => {
|
|
6125
6090
|
$templateCache.put("mock/hello", "<span>Hello, {{name}}!</span>");
|
|
6126
6091
|
$rootScope.name = "Elvis";
|
|
6127
|
-
element = $compile('<div><b
|
|
6092
|
+
element = $compile('<div><b hello=""></b></div>')($rootScope);
|
|
6128
6093
|
|
|
6129
6094
|
$rootScope.$digest();
|
|
6130
6095
|
|
|
6131
6096
|
setTimeout(() => {
|
|
6132
6097
|
expect(element[0].outerHTML).toEqual(
|
|
6133
|
-
'<div><b
|
|
6098
|
+
'<div><b hello=""><span>Hello, Elvis!</span></b></div>',
|
|
6134
6099
|
);
|
|
6135
6100
|
done();
|
|
6136
6101
|
}, 100);
|
|
@@ -6139,24 +6104,24 @@ describe("$compile", () => {
|
|
|
6139
6104
|
it("should compile, link and flush the template inline", () => {
|
|
6140
6105
|
$templateCache.put("mock/div", "<span>Hello, {{name}}!</span>");
|
|
6141
6106
|
$rootScope.name = "Elvis";
|
|
6142
|
-
element = $compile("<div><b
|
|
6107
|
+
element = $compile("<div><b i-hello></b></div>")($rootScope);
|
|
6143
6108
|
|
|
6144
6109
|
$rootScope.$digest();
|
|
6145
6110
|
|
|
6146
6111
|
expect(element[0].outerHTML).toBe(
|
|
6147
|
-
'<div><span
|
|
6112
|
+
'<div><span i-hello="">Hello, Elvis!</span></div>',
|
|
6148
6113
|
);
|
|
6149
6114
|
});
|
|
6150
6115
|
|
|
6151
6116
|
it("should compile template when replacing element in another template", () => {
|
|
6152
6117
|
$templateCache.put("mock/hello", "<div replace></div>");
|
|
6153
6118
|
$rootScope.name = "Elvis";
|
|
6154
|
-
element = $compile('<div><b
|
|
6119
|
+
element = $compile('<div><b hello=""></b></div>')($rootScope);
|
|
6155
6120
|
|
|
6156
6121
|
$rootScope.$digest();
|
|
6157
6122
|
|
|
6158
6123
|
expect(element[0].outerHTML).toEqual(
|
|
6159
|
-
'<div><b
|
|
6124
|
+
'<div><b hello=""><span replace="">Hello, Elvis!</span></b></div>',
|
|
6160
6125
|
);
|
|
6161
6126
|
});
|
|
6162
6127
|
|
|
@@ -6177,10 +6142,10 @@ describe("$compile", () => {
|
|
|
6177
6142
|
$rootScope.name = "Elvis";
|
|
6178
6143
|
const template = $compile(
|
|
6179
6144
|
"<div>" +
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
"<b
|
|
6183
|
-
"<b
|
|
6145
|
+
"<b hello></b>" +
|
|
6146
|
+
"<b cau></b>" +
|
|
6147
|
+
"<b c-error></b>" +
|
|
6148
|
+
"<b l-error></b>" +
|
|
6184
6149
|
"</div>",
|
|
6185
6150
|
);
|
|
6186
6151
|
let e1;
|
|
@@ -6208,7 +6173,7 @@ describe("$compile", () => {
|
|
|
6208
6173
|
|
|
6209
6174
|
it("should resolve widgets after cloning in append mode without $templateCache", (done) => {
|
|
6210
6175
|
$rootScope.expr = "Elvis";
|
|
6211
|
-
const template = $compile(
|
|
6176
|
+
const template = $compile("<div cau></div>");
|
|
6212
6177
|
let e1;
|
|
6213
6178
|
let e2;
|
|
6214
6179
|
|
|
@@ -6233,10 +6198,10 @@ describe("$compile", () => {
|
|
|
6233
6198
|
$rootScope.name = "Elvis";
|
|
6234
6199
|
const template = $compile(
|
|
6235
6200
|
"<div>" +
|
|
6236
|
-
"<b
|
|
6237
|
-
"<b
|
|
6238
|
-
"<b
|
|
6239
|
-
"<b
|
|
6201
|
+
"<b i-hello></b>" +
|
|
6202
|
+
"<b i-cau></b>" +
|
|
6203
|
+
"<b i-c-error></b>" +
|
|
6204
|
+
"<b i-l-error></b>" +
|
|
6240
6205
|
"</div>",
|
|
6241
6206
|
);
|
|
6242
6207
|
let e1;
|
|
@@ -6260,7 +6225,7 @@ describe("$compile", () => {
|
|
|
6260
6225
|
|
|
6261
6226
|
it("should resolve widgets after cloning in inline mode without $templateCache", (done) => {
|
|
6262
6227
|
$rootScope.expr = "Elvis";
|
|
6263
|
-
const template = $compile('<div
|
|
6228
|
+
const template = $compile('<div i-cau=""></div>');
|
|
6264
6229
|
let e1;
|
|
6265
6230
|
let e2;
|
|
6266
6231
|
|
|
@@ -6283,7 +6248,7 @@ describe("$compile", () => {
|
|
|
6283
6248
|
it("should be implicitly terminal and not compile placeholder content in append", () => {
|
|
6284
6249
|
// we can't compile the contents because that would result in a memory leak
|
|
6285
6250
|
$templateCache.put("mock/hello", "Hello!");
|
|
6286
|
-
element = $compile('<div><b
|
|
6251
|
+
element = $compile('<div><b hello=""><div log></div></b></div>')(
|
|
6287
6252
|
$rootScope,
|
|
6288
6253
|
);
|
|
6289
6254
|
|
|
@@ -6294,7 +6259,7 @@ describe("$compile", () => {
|
|
|
6294
6259
|
// we can't compile the contents because that would result in a memory leak
|
|
6295
6260
|
|
|
6296
6261
|
$templateCache.put("mock/hello", "Hello!");
|
|
6297
|
-
element = $compile("<div><b
|
|
6262
|
+
element = $compile("<div><b i-hello><div log></div></b></div>")(
|
|
6298
6263
|
$rootScope,
|
|
6299
6264
|
);
|
|
6300
6265
|
|
|
@@ -6303,10 +6268,10 @@ describe("$compile", () => {
|
|
|
6303
6268
|
|
|
6304
6269
|
// TODO: Figure out why the test fails twice
|
|
6305
6270
|
it("should throw an error and clear element content if the template fails to load", (done) => {
|
|
6306
|
-
element = $compile(
|
|
6271
|
+
element = $compile("<div><b 401>content</b></div>")($rootScope);
|
|
6307
6272
|
setTimeout(() => {
|
|
6308
6273
|
expect(errors.length).toBe(2);
|
|
6309
|
-
expect(element[0].outerHTML).toBe('<div><b
|
|
6274
|
+
expect(element[0].outerHTML).toBe('<div><b 401=""></b></div>');
|
|
6310
6275
|
done();
|
|
6311
6276
|
}, 1000);
|
|
6312
6277
|
});
|
|
@@ -6343,7 +6308,7 @@ describe("$compile", () => {
|
|
|
6343
6308
|
module = angular.module("test1", ["ng"]).directive(
|
|
6344
6309
|
"hello",
|
|
6345
6310
|
valueFn({
|
|
6346
|
-
restrict: "
|
|
6311
|
+
restrict: "A",
|
|
6347
6312
|
templateUrl: "mock/hello",
|
|
6348
6313
|
transclude: true,
|
|
6349
6314
|
}),
|
|
@@ -6502,7 +6467,7 @@ describe("$compile", () => {
|
|
|
6502
6467
|
"mock/hello",
|
|
6503
6468
|
"<span>3==<span ng-transclude></span></span>",
|
|
6504
6469
|
);
|
|
6505
|
-
element = JQLite('<b
|
|
6470
|
+
element = JQLite('<b hello="">{{1+2}}</b>');
|
|
6506
6471
|
$compile(element)($rootScope);
|
|
6507
6472
|
$rootScope.$digest();
|
|
6508
6473
|
expect(element.text()).toEqual("3==3");
|
|
@@ -6520,7 +6485,7 @@ describe("$compile", () => {
|
|
|
6520
6485
|
"<span>i=<span ng-transclude></span>;</span>",
|
|
6521
6486
|
);
|
|
6522
6487
|
element = JQLite(
|
|
6523
|
-
`<div><b
|
|
6488
|
+
`<div><b hello ng-repeat="i in [${is}]">{{i}}</b></div>`,
|
|
6524
6489
|
);
|
|
6525
6490
|
$compile(element)($rootScope);
|
|
6526
6491
|
$rootScope.$digest();
|
|
@@ -6913,7 +6878,7 @@ describe("$compile", () => {
|
|
|
6913
6878
|
["", "a", "b"].forEach((name) => {
|
|
6914
6879
|
module.directive(`scope${name.toUpperCase()}`, () => ({
|
|
6915
6880
|
scope: true,
|
|
6916
|
-
restrict: "
|
|
6881
|
+
restrict: "A",
|
|
6917
6882
|
compile() {
|
|
6918
6883
|
return {
|
|
6919
6884
|
pre(scope, element) {
|
|
@@ -6925,7 +6890,7 @@ describe("$compile", () => {
|
|
|
6925
6890
|
}));
|
|
6926
6891
|
module.directive(`iscope${name.toUpperCase()}`, () => ({
|
|
6927
6892
|
scope: {},
|
|
6928
|
-
restrict: "
|
|
6893
|
+
restrict: "A",
|
|
6929
6894
|
compile() {
|
|
6930
6895
|
return function (scope, element) {
|
|
6931
6896
|
iscope = scope;
|
|
@@ -6936,7 +6901,7 @@ describe("$compile", () => {
|
|
|
6936
6901
|
}));
|
|
6937
6902
|
module.directive(`tscope${name.toUpperCase()}`, () => ({
|
|
6938
6903
|
scope: true,
|
|
6939
|
-
restrict: "
|
|
6904
|
+
restrict: "A",
|
|
6940
6905
|
templateUrl: "tscope.html",
|
|
6941
6906
|
compile() {
|
|
6942
6907
|
return function (scope, element) {
|
|
@@ -6947,7 +6912,7 @@ describe("$compile", () => {
|
|
|
6947
6912
|
}));
|
|
6948
6913
|
module.directive(`stscope${name.toUpperCase()}`, () => ({
|
|
6949
6914
|
scope: true,
|
|
6950
|
-
restrict: "
|
|
6915
|
+
restrict: "A",
|
|
6951
6916
|
template: "<span></span>",
|
|
6952
6917
|
compile() {
|
|
6953
6918
|
return function (scope, element) {
|
|
@@ -6959,7 +6924,7 @@ describe("$compile", () => {
|
|
|
6959
6924
|
module.directive(`trscope${name.toUpperCase()}`, () => ({
|
|
6960
6925
|
scope: true,
|
|
6961
6926
|
replace: true,
|
|
6962
|
-
restrict: "
|
|
6927
|
+
restrict: "A",
|
|
6963
6928
|
templateUrl: "trscope.html",
|
|
6964
6929
|
compile() {
|
|
6965
6930
|
return function (scope, element) {
|
|
@@ -6970,7 +6935,7 @@ describe("$compile", () => {
|
|
|
6970
6935
|
}));
|
|
6971
6936
|
module.directive(`tiscope${name.toUpperCase()}`, () => ({
|
|
6972
6937
|
scope: {},
|
|
6973
|
-
restrict: "
|
|
6938
|
+
restrict: "A",
|
|
6974
6939
|
templateUrl: "tiscope.html",
|
|
6975
6940
|
compile() {
|
|
6976
6941
|
return function (scope, element) {
|
|
@@ -6982,7 +6947,7 @@ describe("$compile", () => {
|
|
|
6982
6947
|
}));
|
|
6983
6948
|
module.directive(`stiscope${name.toUpperCase()}`, () => ({
|
|
6984
6949
|
scope: {},
|
|
6985
|
-
restrict: "
|
|
6950
|
+
restrict: "A",
|
|
6986
6951
|
template: "<span></span>",
|
|
6987
6952
|
compile() {
|
|
6988
6953
|
return function (scope, element) {
|
|
@@ -6994,7 +6959,7 @@ describe("$compile", () => {
|
|
|
6994
6959
|
}));
|
|
6995
6960
|
});
|
|
6996
6961
|
module.directive("log", () => ({
|
|
6997
|
-
restrict: "
|
|
6962
|
+
restrict: "A",
|
|
6998
6963
|
link: {
|
|
6999
6964
|
pre(scope) {
|
|
7000
6965
|
log.push(
|
|
@@ -7125,12 +7090,12 @@ describe("$compile", () => {
|
|
|
7125
7090
|
it("should correctly create the scope hierarchy", () => {
|
|
7126
7091
|
element = $compile(
|
|
7127
7092
|
"<div>" + // 1
|
|
7128
|
-
"<b
|
|
7129
|
-
"<b
|
|
7130
|
-
"<b
|
|
7093
|
+
"<b scope>" + // 2
|
|
7094
|
+
"<b scope><b log></b></b>" + // 3
|
|
7095
|
+
"<b log></b>" +
|
|
7131
7096
|
"</b>" +
|
|
7132
|
-
"<b
|
|
7133
|
-
"<b
|
|
7097
|
+
"<b scope>" + // 4
|
|
7098
|
+
"<b log></b>" +
|
|
7134
7099
|
"</b>" +
|
|
7135
7100
|
"</div>",
|
|
7136
7101
|
)($rootScope);
|
|
@@ -7138,19 +7103,19 @@ describe("$compile", () => {
|
|
|
7138
7103
|
});
|
|
7139
7104
|
|
|
7140
7105
|
it("should allow more than one new scope directives per element, but directives should share the scope", () => {
|
|
7141
|
-
element = $compile(
|
|
7106
|
+
element = $compile("<div scope-a scope-b></div>")($rootScope);
|
|
7142
7107
|
expect(log.length).toEqual(2);
|
|
7143
7108
|
});
|
|
7144
7109
|
|
|
7145
7110
|
it("should not allow more than one isolate scope creation per element", () => {
|
|
7146
7111
|
expect(() => {
|
|
7147
|
-
$compile(
|
|
7112
|
+
$compile("<div iscope-a scope-b></div>")($rootScope);
|
|
7148
7113
|
}).toThrowError(/multidir/);
|
|
7149
7114
|
});
|
|
7150
7115
|
|
|
7151
7116
|
it("should not allow more than one isolate/new scope creation per element regardless of `templateUrl`", () => {
|
|
7152
7117
|
$templateCache.put("tiscope.html", "<div>Hello, world !</div>");
|
|
7153
|
-
$compile(
|
|
7118
|
+
$compile("<div tiscope-a scope-b></div>")($rootScope);
|
|
7154
7119
|
$rootScope.$digest();
|
|
7155
7120
|
expect(log[0].match(/multidir/)).toBeTruthy();
|
|
7156
7121
|
});
|
|
@@ -7573,7 +7538,7 @@ describe("$compile", () => {
|
|
|
7573
7538
|
// .module("fakeIsoledScopeModule", [])
|
|
7574
7539
|
// .directive("fakeScope", () => ({
|
|
7575
7540
|
// scope: true,
|
|
7576
|
-
// restrict: "
|
|
7541
|
+
// restrict: "A",
|
|
7577
7542
|
// compile() {
|
|
7578
7543
|
// return {
|
|
7579
7544
|
// pre(scope, element) {
|
|
@@ -7585,7 +7550,7 @@ describe("$compile", () => {
|
|
|
7585
7550
|
// }))
|
|
7586
7551
|
// .directive("fakeIScope", () => ({
|
|
7587
7552
|
// scope: {},
|
|
7588
|
-
// restrict: "
|
|
7553
|
+
// restrict: "A",
|
|
7589
7554
|
// compile() {
|
|
7590
7555
|
// return function (scope, element) {
|
|
7591
7556
|
// iscope = scope;
|
|
@@ -7599,7 +7564,7 @@ describe("$compile", () => {
|
|
|
7599
7564
|
// module("fakeIsoledScopeModule", () => {
|
|
7600
7565
|
// directive("anonymModuleScopeDirective", () => ({
|
|
7601
7566
|
// scope: true,
|
|
7602
|
-
// restrict: "
|
|
7567
|
+
// restrict: "A",
|
|
7603
7568
|
// compile() {
|
|
7604
7569
|
// return {
|
|
7605
7570
|
// pre(scope, element) {
|
|
@@ -8128,169 +8093,6 @@ describe("$compile", () => {
|
|
|
8128
8093
|
});
|
|
8129
8094
|
});
|
|
8130
8095
|
|
|
8131
|
-
describe("collector", () => {
|
|
8132
|
-
let module;
|
|
8133
|
-
let collected;
|
|
8134
|
-
beforeEach(() => {
|
|
8135
|
-
log = [];
|
|
8136
|
-
collected = false;
|
|
8137
|
-
module = window.angular.module("test1", ["ng"]);
|
|
8138
|
-
module.directive("testCollect", () => ({
|
|
8139
|
-
restrict: "EA",
|
|
8140
|
-
link() {
|
|
8141
|
-
collected = true;
|
|
8142
|
-
},
|
|
8143
|
-
}));
|
|
8144
|
-
createInjector(["test1"]).invoke((_$compile_, _$rootScope_) => {
|
|
8145
|
-
$compile = _$compile_;
|
|
8146
|
-
$rootScope = _$rootScope_;
|
|
8147
|
-
});
|
|
8148
|
-
});
|
|
8149
|
-
|
|
8150
|
-
forEach(
|
|
8151
|
-
[
|
|
8152
|
-
{ commentEnabled: true, cssEnabled: true },
|
|
8153
|
-
{ commentEnabled: true, cssEnabled: false },
|
|
8154
|
-
{ commentEnabled: false, cssEnabled: true },
|
|
8155
|
-
{ commentEnabled: false, cssEnabled: false },
|
|
8156
|
-
],
|
|
8157
|
-
(config) => {
|
|
8158
|
-
describe(
|
|
8159
|
-
`commentDirectivesEnabled(${config.commentEnabled}) ` +
|
|
8160
|
-
`cssClassDirectivesEnabled(${config.cssEnabled})`,
|
|
8161
|
-
() => {
|
|
8162
|
-
let collected = false;
|
|
8163
|
-
beforeEach(() => {
|
|
8164
|
-
collected = false;
|
|
8165
|
-
module = window.angular.module("test1", ["ng"]);
|
|
8166
|
-
module.directive("testCollect", () => ({
|
|
8167
|
-
restrict: "EA",
|
|
8168
|
-
link() {
|
|
8169
|
-
collected = true;
|
|
8170
|
-
},
|
|
8171
|
-
}));
|
|
8172
|
-
createInjector([
|
|
8173
|
-
"test1",
|
|
8174
|
-
($compileProvider) => {
|
|
8175
|
-
$compileProvider.commentDirectivesEnabled(
|
|
8176
|
-
config.commentEnabled,
|
|
8177
|
-
);
|
|
8178
|
-
$compileProvider.cssClassDirectivesEnabled(
|
|
8179
|
-
config.cssEnabled,
|
|
8180
|
-
);
|
|
8181
|
-
},
|
|
8182
|
-
]).invoke((_$compile_, _$rootScope_) => {
|
|
8183
|
-
$compile = _$compile_;
|
|
8184
|
-
$rootScope = _$rootScope_;
|
|
8185
|
-
});
|
|
8186
|
-
});
|
|
8187
|
-
|
|
8188
|
-
it("should not prevent to compile entity directives", () => {
|
|
8189
|
-
element = $compile("<test-collect></test-collect>")($rootScope);
|
|
8190
|
-
expect(collected).toBe(true);
|
|
8191
|
-
});
|
|
8192
|
-
|
|
8193
|
-
it("should not prevent to compile attribute directives", () => {
|
|
8194
|
-
element = $compile("<span test-collect></span>")($rootScope);
|
|
8195
|
-
expect(collected).toBe(true);
|
|
8196
|
-
});
|
|
8197
|
-
|
|
8198
|
-
it("should not prevent to compile interpolated expressions", () => {
|
|
8199
|
-
element = $compile('<span>{{"text "+"interpolated"}}</span>')(
|
|
8200
|
-
$rootScope,
|
|
8201
|
-
);
|
|
8202
|
-
$rootScope.$apply();
|
|
8203
|
-
expect(element.text()).toBe("text interpolated");
|
|
8204
|
-
});
|
|
8205
|
-
|
|
8206
|
-
it("should interpolate expressions inside class attribute", () => {
|
|
8207
|
-
$rootScope.interpolateMe = "interpolated";
|
|
8208
|
-
const html = '<div class="{{interpolateMe}}"></div>';
|
|
8209
|
-
element = $compile(html)($rootScope);
|
|
8210
|
-
$rootScope.$apply();
|
|
8211
|
-
expect(
|
|
8212
|
-
element[0].classList.contains("interpolated"),
|
|
8213
|
-
).toBeTrue();
|
|
8214
|
-
});
|
|
8215
|
-
},
|
|
8216
|
-
);
|
|
8217
|
-
},
|
|
8218
|
-
);
|
|
8219
|
-
|
|
8220
|
-
it("should configure comment directives true by default", () => {
|
|
8221
|
-
createInjector([
|
|
8222
|
-
"ng",
|
|
8223
|
-
($compileProvider) => {
|
|
8224
|
-
const commentDirectivesEnabled =
|
|
8225
|
-
$compileProvider.commentDirectivesEnabled();
|
|
8226
|
-
expect(commentDirectivesEnabled).toBe(true);
|
|
8227
|
-
},
|
|
8228
|
-
]);
|
|
8229
|
-
});
|
|
8230
|
-
|
|
8231
|
-
it("should return self when setting commentDirectivesEnabled", () => {
|
|
8232
|
-
createInjector([
|
|
8233
|
-
"ng",
|
|
8234
|
-
($compileProvider) => {
|
|
8235
|
-
const self = $compileProvider.commentDirectivesEnabled(true);
|
|
8236
|
-
expect(self).toBe($compileProvider);
|
|
8237
|
-
},
|
|
8238
|
-
]);
|
|
8239
|
-
});
|
|
8240
|
-
|
|
8241
|
-
it("should cache commentDirectivesEnabled value when configure ends", () => {
|
|
8242
|
-
let $compileProvider;
|
|
8243
|
-
createInjector([
|
|
8244
|
-
"ng",
|
|
8245
|
-
(_$compileProvider_) => {
|
|
8246
|
-
$compileProvider = _$compileProvider_;
|
|
8247
|
-
$compileProvider.commentDirectivesEnabled(false);
|
|
8248
|
-
},
|
|
8249
|
-
]).invoke(($compile, $rootScope) => {
|
|
8250
|
-
$compileProvider.commentDirectivesEnabled(true);
|
|
8251
|
-
const html = "<!-- directive: test-collect -->";
|
|
8252
|
-
element = $compile(`<div>${html}</div>`)($rootScope);
|
|
8253
|
-
expect(collected).toBe(false);
|
|
8254
|
-
});
|
|
8255
|
-
});
|
|
8256
|
-
|
|
8257
|
-
it("should configure css class directives true by default", () => {
|
|
8258
|
-
createInjector([
|
|
8259
|
-
"ng",
|
|
8260
|
-
($compileProvider) => {
|
|
8261
|
-
const cssClassDirectivesEnabled =
|
|
8262
|
-
$compileProvider.cssClassDirectivesEnabled();
|
|
8263
|
-
expect(cssClassDirectivesEnabled).toBe(true);
|
|
8264
|
-
},
|
|
8265
|
-
]);
|
|
8266
|
-
});
|
|
8267
|
-
|
|
8268
|
-
it("should return self when setting cssClassDirectivesEnabled", () => {
|
|
8269
|
-
createInjector([
|
|
8270
|
-
"ng",
|
|
8271
|
-
($compileProvider) => {
|
|
8272
|
-
const self = $compileProvider.cssClassDirectivesEnabled(true);
|
|
8273
|
-
expect(self).toBe($compileProvider);
|
|
8274
|
-
},
|
|
8275
|
-
]);
|
|
8276
|
-
});
|
|
8277
|
-
|
|
8278
|
-
it("should cache cssClassDirectivesEnabled value when configure ends", () => {
|
|
8279
|
-
let $compileProvider;
|
|
8280
|
-
createInjector([
|
|
8281
|
-
"ng",
|
|
8282
|
-
(_$compileProvider_) => {
|
|
8283
|
-
$compileProvider = _$compileProvider_;
|
|
8284
|
-
$compileProvider.cssClassDirectivesEnabled(false);
|
|
8285
|
-
},
|
|
8286
|
-
]).invoke(($compile, $rootScope) => {
|
|
8287
|
-
$compileProvider.cssClassDirectivesEnabled(true);
|
|
8288
|
-
element = $compile('<div class="test-collect"></div>')($rootScope);
|
|
8289
|
-
expect(collected).toBe(false);
|
|
8290
|
-
});
|
|
8291
|
-
});
|
|
8292
|
-
});
|
|
8293
|
-
|
|
8294
8096
|
describe("link phase", () => {
|
|
8295
8097
|
let module, log;
|
|
8296
8098
|
beforeEach(() => {
|
|
@@ -8298,7 +8100,7 @@ describe("$compile", () => {
|
|
|
8298
8100
|
module = window.angular.module("test1", ["ng"]);
|
|
8299
8101
|
["a", "b", "c"].forEach((name) => {
|
|
8300
8102
|
module.directive(name, () => ({
|
|
8301
|
-
restrict: "
|
|
8103
|
+
restrict: "EA",
|
|
8302
8104
|
compile() {
|
|
8303
8105
|
log.push(`t${name.toUpperCase()}`);
|
|
8304
8106
|
return {
|
|
@@ -8415,7 +8217,7 @@ describe("$compile", () => {
|
|
|
8415
8217
|
let value;
|
|
8416
8218
|
module.directive({
|
|
8417
8219
|
input: valueFn({
|
|
8418
|
-
restrict: "
|
|
8220
|
+
restrict: "EA",
|
|
8419
8221
|
link(scope, element, attr) {
|
|
8420
8222
|
value = attr.required;
|
|
8421
8223
|
},
|
|
@@ -8435,7 +8237,7 @@ describe("$compile", () => {
|
|
|
8435
8237
|
let value;
|
|
8436
8238
|
module.directive({
|
|
8437
8239
|
div: valueFn({
|
|
8438
|
-
restrict: "
|
|
8240
|
+
restrict: "EA",
|
|
8439
8241
|
link(scope, element, attr) {
|
|
8440
8242
|
value = attr.required;
|
|
8441
8243
|
},
|
|
@@ -8571,7 +8373,7 @@ describe("$compile", () => {
|
|
|
8571
8373
|
module.directive(
|
|
8572
8374
|
tag,
|
|
8573
8375
|
valueFn({
|
|
8574
|
-
restrict: "
|
|
8376
|
+
restrict: "EA",
|
|
8575
8377
|
link(scope, element, attr) {
|
|
8576
8378
|
scope.attr = attr;
|
|
8577
8379
|
},
|
|
@@ -13790,28 +13592,28 @@ describe("$compile", () => {
|
|
|
13790
13592
|
});
|
|
13791
13593
|
|
|
13792
13594
|
it('should not leak if two "element" transclusions are on the same element', () => {
|
|
13793
|
-
const cacheSize =
|
|
13595
|
+
const cacheSize = CACHE.size;
|
|
13794
13596
|
|
|
13795
13597
|
element = $compile(
|
|
13796
13598
|
'<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>',
|
|
13797
13599
|
)($rootScope);
|
|
13798
|
-
expect(
|
|
13600
|
+
expect(CACHE.size).toEqual(cacheSize + 1);
|
|
13799
13601
|
|
|
13800
13602
|
$rootScope.$apply("xs = [0,1]");
|
|
13801
|
-
expect(
|
|
13603
|
+
expect(CACHE.size).toEqual(cacheSize + 2);
|
|
13802
13604
|
|
|
13803
13605
|
$rootScope.$apply("xs = [0]");
|
|
13804
|
-
expect(
|
|
13606
|
+
expect(CACHE.size).toEqual(cacheSize + 1);
|
|
13805
13607
|
|
|
13806
13608
|
$rootScope.$apply("xs = []");
|
|
13807
|
-
expect(
|
|
13609
|
+
expect(CACHE.size).toEqual(cacheSize + 1);
|
|
13808
13610
|
|
|
13809
13611
|
element.remove();
|
|
13810
|
-
expect(
|
|
13612
|
+
expect(CACHE.size).toEqual(cacheSize + 0);
|
|
13811
13613
|
});
|
|
13812
13614
|
|
|
13813
13615
|
it('should not leak if two "element" transclusions are on the same element', () => {
|
|
13814
|
-
const cacheSize =
|
|
13616
|
+
const cacheSize = CACHE.size;
|
|
13815
13617
|
element = $compile(
|
|
13816
13618
|
'<div><div ng-repeat="x in xs" ng-if="val">{{x}}</div></div>',
|
|
13817
13619
|
)($rootScope);
|
|
@@ -13819,20 +13621,20 @@ describe("$compile", () => {
|
|
|
13819
13621
|
$rootScope.$apply("xs = [0,1]");
|
|
13820
13622
|
// At this point we have a bunch of comment placeholders but no real transcluded elements
|
|
13821
13623
|
// So the cache only contains the root element's data
|
|
13822
|
-
expect(
|
|
13624
|
+
expect(CACHE.size).toEqual(cacheSize + 1);
|
|
13823
13625
|
|
|
13824
13626
|
$rootScope.$apply("val = true");
|
|
13825
13627
|
// Now we have two concrete transcluded elements plus some comments so two more cache items
|
|
13826
|
-
expect(
|
|
13628
|
+
expect(CACHE.size).toEqual(cacheSize + 3);
|
|
13827
13629
|
|
|
13828
13630
|
$rootScope.$apply("val = false");
|
|
13829
13631
|
// Once again we only have comments so no transcluded elements and the cache is back to just
|
|
13830
13632
|
// the root element
|
|
13831
|
-
expect(
|
|
13633
|
+
expect(CACHE.size).toEqual(cacheSize + 1);
|
|
13832
13634
|
|
|
13833
13635
|
element.remove();
|
|
13834
13636
|
// Now we've even removed the root element along with its cache
|
|
13835
|
-
expect(
|
|
13637
|
+
expect(CACHE.size).toEqual(cacheSize + 0);
|
|
13836
13638
|
});
|
|
13837
13639
|
|
|
13838
13640
|
// it("should not leak when continuing the compilation of elements on a scope that was destroyed", () => {
|
|
@@ -13857,7 +13659,7 @@ describe("$compile", () => {
|
|
|
13857
13659
|
// link: linkFn,
|
|
13858
13660
|
// }));
|
|
13859
13661
|
// initInjector("test1");
|
|
13860
|
-
// const cacheSize =
|
|
13662
|
+
// const cacheSize = CACHE.size;
|
|
13861
13663
|
// $templateCache.put("red.html", "<p>red</p>");
|
|
13862
13664
|
// const template = $compile(
|
|
13863
13665
|
// '<div ng-controller="Leak">' +
|
|
@@ -13872,7 +13674,7 @@ describe("$compile", () => {
|
|
|
13872
13674
|
// $rootScope.$digest();
|
|
13873
13675
|
|
|
13874
13676
|
// expect(linkFn).toHaveBeenCalled();
|
|
13875
|
-
// expect(
|
|
13677
|
+
// expect(CACHE.size).toEqual(cacheSize + 2);
|
|
13876
13678
|
|
|
13877
13679
|
// $templateCache.removeAll();
|
|
13878
13680
|
// const destroyedScope = $rootScope.$new();
|
|
@@ -13903,7 +13705,7 @@ describe("$compile", () => {
|
|
|
13903
13705
|
firstRepeatedElem = element.children(".ng-scope").eq(0);
|
|
13904
13706
|
|
|
13905
13707
|
expect(firstRepeatedElem.data("$scope")).toBeDefined();
|
|
13906
|
-
privateData = CACHE.get(firstRepeatedElem[0]);
|
|
13708
|
+
privateData = CACHE.get(firstRepeatedElem[0][EXPANDO]);
|
|
13907
13709
|
expect(privateData.events).toBeDefined();
|
|
13908
13710
|
|
|
13909
13711
|
expect(privateData.events.click).toBeDefined();
|
|
@@ -13919,7 +13721,7 @@ describe("$compile", () => {
|
|
|
13919
13721
|
|
|
13920
13722
|
expect(destroyCount).toBe(2);
|
|
13921
13723
|
expect(firstRepeatedElem.data("$scope")).not.toBeDefined();
|
|
13922
|
-
privateData = CACHE.get(firstRepeatedElem[0]);
|
|
13724
|
+
privateData = CACHE.get(firstRepeatedElem[0][EXPANDO]);
|
|
13923
13725
|
expect(privateData && privateData.events).not.toBeDefined();
|
|
13924
13726
|
}
|
|
13925
13727
|
|
|
@@ -14808,7 +14610,7 @@ describe("$compile", () => {
|
|
|
14808
14610
|
|
|
14809
14611
|
it("should not leak memory with nested transclusion", () => {
|
|
14810
14612
|
let size;
|
|
14811
|
-
const initialSize =
|
|
14613
|
+
const initialSize = CACHE.size;
|
|
14812
14614
|
|
|
14813
14615
|
element = JQLite(
|
|
14814
14616
|
'<div><ul><li ng-repeat="n in nums">{{n}} => <i ng-if="0 === n%2">Even</i><i ng-if="1 === n%2">Odd</i></li></ul></div>',
|
|
@@ -14817,14 +14619,14 @@ describe("$compile", () => {
|
|
|
14817
14619
|
|
|
14818
14620
|
$rootScope.nums = [0, 1, 2];
|
|
14819
14621
|
$rootScope.$apply();
|
|
14820
|
-
size =
|
|
14622
|
+
size = CACHE.size;
|
|
14821
14623
|
|
|
14822
14624
|
$rootScope.nums = [3, 4, 5];
|
|
14823
14625
|
$rootScope.$apply();
|
|
14824
|
-
expect(
|
|
14626
|
+
expect(CACHE.size).toEqual(size);
|
|
14825
14627
|
|
|
14826
14628
|
element.remove();
|
|
14827
|
-
expect(
|
|
14629
|
+
expect(CACHE.size).toEqual(initialSize);
|
|
14828
14630
|
});
|
|
14829
14631
|
});
|
|
14830
14632
|
|
|
@@ -15126,7 +14928,7 @@ describe("$compile", () => {
|
|
|
15126
14928
|
it("should terminate compilation only for element transclusion", () => {
|
|
15127
14929
|
module
|
|
15128
14930
|
.directive("log", () => ({
|
|
15129
|
-
restrict: "
|
|
14931
|
+
restrict: "A",
|
|
15130
14932
|
priority: 0,
|
|
15131
14933
|
compile: valueFn((scope, element, attrs) => {
|
|
15132
14934
|
log.push(attrs.log || "LOG");
|