@angular-wave/angular.ts 0.0.8 → 0.0.10
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 +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/package.json +2 -3
- package/rollup.config.js +2 -5
- package/src/core/compile.js +73 -109
- package/src/core/root-scope.js +1 -1
- package/src/directive/if.js +2 -7
- package/src/directive/repeat.js +5 -346
- package/src/directive/repeat.md +358 -0
- package/src/directive/switch.js +2 -4
- package/src/exts/messages.js +2 -494
- package/src/exts/messages.md +550 -0
- package/src/injector.md +1 -1
- package/src/jqLite.js +14 -18
- package/src/loader.js +0 -4
- package/test/binding.spec.js +24 -24
- package/test/jqlite.spec.js +0 -56
- package/test/messages/messages.spec.js +2 -4
- package/test/module-test.html +5 -1
- package/test/ng/compile.spec.js +76 -164
- package/test/ng/directive/form.spec.js +1 -1
- package/test/ng/directive/if.spec.js +2 -1
- package/test/ng/directive/include.spec.js +3 -3
- package/test/ng/directive/repeat.spec.js +0 -37
- package/test/ng/directive/switch.spec.js +10 -20
- package/types/jqlite.d.ts +0 -78
- package/dist/angular-ts.cjs.js +0 -1
package/test/binding.spec.js
CHANGED
|
@@ -133,11 +133,11 @@ describe("binding", () => {
|
|
|
133
133
|
$rootScope.$apply();
|
|
134
134
|
expect(form[0].outerHTML).toBe(
|
|
135
135
|
"<ul>" +
|
|
136
|
-
"
|
|
136
|
+
"<!---->" +
|
|
137
137
|
'<li ng-repeat="item in model.items" ng-bind="item.a">A</li>' +
|
|
138
|
-
"
|
|
138
|
+
"<!---->" +
|
|
139
139
|
'<li ng-repeat="item in model.items" ng-bind="item.a">B</li>' +
|
|
140
|
-
"
|
|
140
|
+
"<!---->" +
|
|
141
141
|
"</ul>",
|
|
142
142
|
);
|
|
143
143
|
|
|
@@ -145,13 +145,13 @@ describe("binding", () => {
|
|
|
145
145
|
$rootScope.$apply();
|
|
146
146
|
expect(form[0].outerHTML).toBe(
|
|
147
147
|
"<ul>" +
|
|
148
|
-
"
|
|
148
|
+
"<!---->" +
|
|
149
149
|
'<li ng-repeat="item in model.items" ng-bind="item.a">C</li>' +
|
|
150
|
-
"
|
|
150
|
+
"<!---->" +
|
|
151
151
|
'<li ng-repeat="item in model.items" ng-bind="item.a">A</li>' +
|
|
152
|
-
"
|
|
152
|
+
"<!---->" +
|
|
153
153
|
'<li ng-repeat="item in model.items" ng-bind="item.a">B</li>' +
|
|
154
|
-
"
|
|
154
|
+
"<!---->" +
|
|
155
155
|
"</ul>",
|
|
156
156
|
);
|
|
157
157
|
|
|
@@ -159,11 +159,11 @@ describe("binding", () => {
|
|
|
159
159
|
$rootScope.$apply();
|
|
160
160
|
expect(form[0].outerHTML).toBe(
|
|
161
161
|
"<ul>" +
|
|
162
|
-
"
|
|
162
|
+
"<!---->" +
|
|
163
163
|
'<li ng-repeat="item in model.items" ng-bind="item.a">A</li>' +
|
|
164
|
-
"
|
|
164
|
+
"<!---->" +
|
|
165
165
|
'<li ng-repeat="item in model.items" ng-bind="item.a">B</li>' +
|
|
166
|
-
"
|
|
166
|
+
"<!---->" +
|
|
167
167
|
"</ul>",
|
|
168
168
|
);
|
|
169
169
|
|
|
@@ -182,9 +182,9 @@ describe("binding", () => {
|
|
|
182
182
|
$rootScope.$apply();
|
|
183
183
|
expect(element[0].outerHTML).toBe(
|
|
184
184
|
"<ul>" +
|
|
185
|
-
"
|
|
185
|
+
"<!---->" +
|
|
186
186
|
'<li ng-repeat="item in model.items"><span ng-bind="item.a">A</span></li>' +
|
|
187
|
-
"
|
|
187
|
+
"<!---->" +
|
|
188
188
|
"</ul>",
|
|
189
189
|
);
|
|
190
190
|
});
|
|
@@ -257,19 +257,19 @@ describe("binding", () => {
|
|
|
257
257
|
|
|
258
258
|
expect(element[0].outerHTML).toBe(
|
|
259
259
|
`<div>` +
|
|
260
|
-
|
|
260
|
+
`<!---->` +
|
|
261
261
|
`<div ng-repeat="m in model" name="a">` +
|
|
262
|
-
|
|
263
|
-
`<ul name="a1" ng-repeat="i in m.item"></ul
|
|
264
|
-
`<ul name="a2" ng-repeat="i in m.item"></ul
|
|
265
|
-
`</div
|
|
262
|
+
`<!---->` +
|
|
263
|
+
`<ul name="a1" ng-repeat="i in m.item"></ul><!---->` +
|
|
264
|
+
`<ul name="a2" ng-repeat="i in m.item"></ul><!---->` +
|
|
265
|
+
`</div><!---->` +
|
|
266
266
|
`<div ng-repeat="m in model" name="b">` +
|
|
267
|
-
|
|
267
|
+
`<!---->` +
|
|
268
268
|
`<ul name="b1" ng-repeat="i in m.item"></ul>` +
|
|
269
|
-
|
|
269
|
+
`<!---->` +
|
|
270
270
|
`<ul name="b2" ng-repeat="i in m.item"></ul>` +
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
`<!----></div>` +
|
|
272
|
+
`<!----></div>`,
|
|
273
273
|
);
|
|
274
274
|
});
|
|
275
275
|
|
|
@@ -475,11 +475,11 @@ describe("binding", () => {
|
|
|
475
475
|
$rootScope.$apply();
|
|
476
476
|
expect(element[0].outerHTML).toBe(
|
|
477
477
|
"<ul>" +
|
|
478
|
-
"
|
|
478
|
+
"<!---->" +
|
|
479
479
|
'<li ng-repeat="(k,v) in {a:0,b:1}" ng-bind="k + v">a0</li>' +
|
|
480
|
-
"
|
|
480
|
+
"<!---->" +
|
|
481
481
|
'<li ng-repeat="(k,v) in {a:0,b:1}" ng-bind="k + v">b1</li>' +
|
|
482
|
-
"
|
|
482
|
+
"<!---->" +
|
|
483
483
|
"</ul>",
|
|
484
484
|
);
|
|
485
485
|
});
|
package/test/jqlite.spec.js
CHANGED
|
@@ -1684,62 +1684,6 @@ describe("jqLite", () => {
|
|
|
1684
1684
|
});
|
|
1685
1685
|
});
|
|
1686
1686
|
|
|
1687
|
-
describe("one", () => {
|
|
1688
|
-
it("should only fire the callback once", () => {
|
|
1689
|
-
const element = jqLite(a);
|
|
1690
|
-
const spy = jasmine.createSpy("click");
|
|
1691
|
-
|
|
1692
|
-
element.one("click", spy);
|
|
1693
|
-
browserTrigger(element, "click");
|
|
1694
|
-
expect(spy).toHaveBeenCalled();
|
|
1695
|
-
|
|
1696
|
-
browserTrigger(element, "click");
|
|
1697
|
-
expect(spy).toHaveBeenCalled();
|
|
1698
|
-
});
|
|
1699
|
-
|
|
1700
|
-
it("should deregister when off is called", () => {
|
|
1701
|
-
const element = jqLite(a);
|
|
1702
|
-
const spy = jasmine.createSpy("click");
|
|
1703
|
-
|
|
1704
|
-
element.one("click", spy);
|
|
1705
|
-
element.off("click", spy);
|
|
1706
|
-
|
|
1707
|
-
browserTrigger(element, "click");
|
|
1708
|
-
expect(spy).not.toHaveBeenCalled();
|
|
1709
|
-
});
|
|
1710
|
-
|
|
1711
|
-
it("should return the same event object just as on() does", () => {
|
|
1712
|
-
const element = jqLite(a);
|
|
1713
|
-
let eventA;
|
|
1714
|
-
let eventB;
|
|
1715
|
-
element.on("click", (event) => {
|
|
1716
|
-
eventA = event;
|
|
1717
|
-
});
|
|
1718
|
-
element.one("click", (event) => {
|
|
1719
|
-
eventB = event;
|
|
1720
|
-
});
|
|
1721
|
-
|
|
1722
|
-
browserTrigger(element, "click");
|
|
1723
|
-
expect(eventA).toEqual(eventB);
|
|
1724
|
-
});
|
|
1725
|
-
|
|
1726
|
-
it("should not remove other event handlers of the same type after execution", () => {
|
|
1727
|
-
const element = jqLite(a);
|
|
1728
|
-
const calls = [];
|
|
1729
|
-
element.one("click", (event) => {
|
|
1730
|
-
calls.push("one");
|
|
1731
|
-
});
|
|
1732
|
-
element.on("click", (event) => {
|
|
1733
|
-
calls.push("on");
|
|
1734
|
-
});
|
|
1735
|
-
|
|
1736
|
-
browserTrigger(element, "click");
|
|
1737
|
-
browserTrigger(element, "click");
|
|
1738
|
-
|
|
1739
|
-
expect(calls).toEqual(["one", "on", "on"]);
|
|
1740
|
-
});
|
|
1741
|
-
});
|
|
1742
|
-
|
|
1743
1687
|
describe("replaceWith", () => {
|
|
1744
1688
|
it("should replaceWith", () => {
|
|
1745
1689
|
const root = jqLite("<div>").html("before-<div></div>after");
|
|
@@ -577,9 +577,7 @@ describe("ngMessages", () => {
|
|
|
577
577
|
$rootScope.$digest(); // The next digest triggers the error
|
|
578
578
|
|
|
579
579
|
// Make sure removing the element triggers the deregistration in ngMessages
|
|
580
|
-
expect(trim(deregisterSpy.calls.mostRecent().args[0].nodeValue)).toBe(
|
|
581
|
-
"ngMessage: a",
|
|
582
|
-
);
|
|
580
|
+
expect(trim(deregisterSpy.calls.mostRecent().args[0].nodeValue)).toBe("");
|
|
583
581
|
expect(messageChildren(element).length).toBe(0);
|
|
584
582
|
});
|
|
585
583
|
|
|
@@ -619,7 +617,7 @@ describe("ngMessages", () => {
|
|
|
619
617
|
|
|
620
618
|
// Make sure removing the element triggers the deregistration in ngMessages
|
|
621
619
|
expect(trim(deregisterSpy.calls.mostRecent().args[0].nodeValue)).toBe(
|
|
622
|
-
"
|
|
620
|
+
"",
|
|
623
621
|
);
|
|
624
622
|
expect(messageChildren(element).length).toBe(1);
|
|
625
623
|
expect(trim(element.text())).toEqual("A");
|
package/test/module-test.html
CHANGED
|
@@ -5,11 +5,15 @@
|
|
|
5
5
|
<script type="module" src="../src/index.js"></script>
|
|
6
6
|
</head>
|
|
7
7
|
<body ng-app>
|
|
8
|
-
<div>
|
|
8
|
+
<div ng-init='list = [{ name: "x" }, { name: "y" }, { name: "z" }]'>
|
|
9
9
|
<label>Name:</label>
|
|
10
10
|
<input type="text" ng-model="yourName" placeholder="Enter a name here" />
|
|
11
11
|
<hr />
|
|
12
12
|
<h1>Hello {{yourName}}!</h1>
|
|
13
|
+
|
|
14
|
+
<ul ng-repeat="i in list">
|
|
15
|
+
<li>{{ i.name }}</li>
|
|
16
|
+
</ul>
|
|
13
17
|
</div>
|
|
14
18
|
</body>
|
|
15
19
|
</html>
|
package/test/ng/compile.spec.js
CHANGED
|
@@ -1112,15 +1112,16 @@ describe("$compile", () => {
|
|
|
1112
1112
|
});
|
|
1113
1113
|
|
|
1114
1114
|
describe("linking", () => {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1115
|
+
// THERE IS NO SCOPE ATTACHED TO ACTUAL ELEMENTS
|
|
1116
|
+
// it("takes a scope and attaches it to elements", () => {
|
|
1117
|
+
// registerDirectives("myDirective", () => {
|
|
1118
|
+
// return { compile: () => {} };
|
|
1119
|
+
// });
|
|
1120
|
+
// reloadModules();
|
|
1121
|
+
// var el = $("<div my-directive></div>");
|
|
1122
|
+
// $compile(el)($rootScope);
|
|
1123
|
+
// expect(el.data("$scope")).toBe($rootScope);
|
|
1124
|
+
// });
|
|
1124
1125
|
|
|
1125
1126
|
it("calls directive link function with scope", () => {
|
|
1126
1127
|
var givenScope, givenElement, givenAttrs;
|
|
@@ -3576,7 +3577,7 @@ describe("$compile", () => {
|
|
|
3576
3577
|
|
|
3577
3578
|
$compile(el);
|
|
3578
3579
|
|
|
3579
|
-
expect(el[0].innerHTML).toEqual("
|
|
3580
|
+
expect(el[0].innerHTML).toEqual("<!---->");
|
|
3580
3581
|
});
|
|
3581
3582
|
|
|
3582
3583
|
it("includes directive attribute value in comment", () => {
|
|
@@ -3590,7 +3591,7 @@ describe("$compile", () => {
|
|
|
3590
3591
|
|
|
3591
3592
|
$compile(el);
|
|
3592
3593
|
|
|
3593
|
-
expect(el[0].innerHTML).toEqual("
|
|
3594
|
+
expect(el[0].innerHTML).toEqual("<!---->");
|
|
3594
3595
|
});
|
|
3595
3596
|
|
|
3596
3597
|
it("calls directive compile and link with comment", () => {
|
|
@@ -4541,50 +4542,6 @@ describe("$compile", () => {
|
|
|
4541
4542
|
expect($rootScope.valueOne).toBe(51);
|
|
4542
4543
|
expect($rootScope.valueTwo).toBe(51);
|
|
4543
4544
|
});
|
|
4544
|
-
|
|
4545
|
-
it("allows configuring $onChanges TTL", () => {
|
|
4546
|
-
let compileProvider;
|
|
4547
|
-
window.angular.module("myModule", [
|
|
4548
|
-
function ($compileProvider) {
|
|
4549
|
-
expect($compileProvider.onChangesTtl()).toBe(10);
|
|
4550
|
-
$compileProvider.onChangesTtl(50);
|
|
4551
|
-
compileProvider = $compileProvider;
|
|
4552
|
-
expect($compileProvider.onChangesTtl()).toBe(50);
|
|
4553
|
-
$compileProvider.component("myComponent", {
|
|
4554
|
-
bindings: {
|
|
4555
|
-
input: "<",
|
|
4556
|
-
increment: "=",
|
|
4557
|
-
},
|
|
4558
|
-
controller: function () {
|
|
4559
|
-
this.$onChanges = function () {
|
|
4560
|
-
if (this.increment) {
|
|
4561
|
-
this.increment = this.increment + 1;
|
|
4562
|
-
}
|
|
4563
|
-
};
|
|
4564
|
-
},
|
|
4565
|
-
});
|
|
4566
|
-
},
|
|
4567
|
-
]);
|
|
4568
|
-
reloadModules();
|
|
4569
|
-
var watchSpy = jasmine.createSpy();
|
|
4570
|
-
$rootScope.$watch(watchSpy);
|
|
4571
|
-
|
|
4572
|
-
var el = $(
|
|
4573
|
-
"<div>" +
|
|
4574
|
-
'<my-component input="valueOne" increment="valueTwo"></my-component>' +
|
|
4575
|
-
'<my-component input="valueTwo" increment="valueOne"></my-component>' +
|
|
4576
|
-
"</div>",
|
|
4577
|
-
);
|
|
4578
|
-
$compile(el)($rootScope);
|
|
4579
|
-
$rootScope.$apply();
|
|
4580
|
-
|
|
4581
|
-
$rootScope.valueOne = 42;
|
|
4582
|
-
$rootScope.valueTwo = 42;
|
|
4583
|
-
$rootScope.$apply();
|
|
4584
|
-
expect($rootScope.valueOne).toBe(91);
|
|
4585
|
-
expect($rootScope.valueTwo).toBe(91);
|
|
4586
|
-
compileProvider.onChangesTtl(10);
|
|
4587
|
-
});
|
|
4588
4545
|
});
|
|
4589
4546
|
|
|
4590
4547
|
describe("configuration", () => {
|
|
@@ -4654,18 +4611,6 @@ describe("$compile", () => {
|
|
|
4654
4611
|
]);
|
|
4655
4612
|
});
|
|
4656
4613
|
|
|
4657
|
-
it("should allow onChangesTtl to be configured", () => {
|
|
4658
|
-
createInjector([
|
|
4659
|
-
"ng",
|
|
4660
|
-
($compileProvider) => {
|
|
4661
|
-
expect($compileProvider.onChangesTtl()).toBe(10); // the default
|
|
4662
|
-
$compileProvider.onChangesTtl(2);
|
|
4663
|
-
expect($compileProvider.onChangesTtl()).toBe(2);
|
|
4664
|
-
$compileProvider.onChangesTtl(10);
|
|
4665
|
-
},
|
|
4666
|
-
]);
|
|
4667
|
-
});
|
|
4668
|
-
|
|
4669
4614
|
it("should register a directive", () => {
|
|
4670
4615
|
myModule.directive("div", () => ({
|
|
4671
4616
|
restrict: "EA",
|
|
@@ -5025,10 +4970,11 @@ describe("$compile", () => {
|
|
|
5025
4970
|
});
|
|
5026
4971
|
|
|
5027
4972
|
describe("compile phase", () => {
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
4973
|
+
// NO ELEMENT ATTACHMENTS
|
|
4974
|
+
// it("should attach scope to the document node when it is compiled explicitly", () => {
|
|
4975
|
+
// $compile($document)($rootScope);
|
|
4976
|
+
// expect($document.scope()).toBe($rootScope);
|
|
4977
|
+
// });
|
|
5032
4978
|
|
|
5033
4979
|
it("should not wrap root text nodes in spans", () => {
|
|
5034
4980
|
element = JQLite("<div> <div>A</div>\n <div>B</div>C\t\n </div>");
|
|
@@ -5050,6 +4996,7 @@ describe("$compile", () => {
|
|
|
5050
4996
|
// We compile the contents of element (i.e. not element itself)
|
|
5051
4997
|
// Then delete these contents and check the cache has been reset to zero
|
|
5052
4998
|
// Clear cache
|
|
4999
|
+
// Update: THIS TEST IS IRRELEVANT IF WE DONT POLLUTE THE CACHE
|
|
5053
5000
|
CACHE.clear();
|
|
5054
5001
|
window.angular.module("test1", ["ng"]);
|
|
5055
5002
|
createInjector(["test1"]).invoke(($compile) => {
|
|
@@ -5057,7 +5004,7 @@ describe("$compile", () => {
|
|
|
5057
5004
|
// First with only elements at the top level
|
|
5058
5005
|
element = JQLite("<div><div></div></div>");
|
|
5059
5006
|
$compile(element[0].childNodes)($rootScope);
|
|
5060
|
-
expect(CACHE.size).toEqual(2);
|
|
5007
|
+
// expect(CACHE.size).toEqual(2);
|
|
5061
5008
|
element.empty();
|
|
5062
5009
|
expect(CACHE.size).toEqual(1);
|
|
5063
5010
|
|
|
@@ -5077,7 +5024,7 @@ describe("$compile", () => {
|
|
|
5077
5024
|
// Finally with empty text nodes at the top level
|
|
5078
5025
|
element = JQLite("<div> \n<div></div> </div>");
|
|
5079
5026
|
$compile(element[0].childNodes)($rootScope);
|
|
5080
|
-
expect(CACHE.size).toEqual(2);
|
|
5027
|
+
//expect(CACHE.size).toEqual(2);
|
|
5081
5028
|
element.empty();
|
|
5082
5029
|
expect(CACHE.size).toEqual(1);
|
|
5083
5030
|
});
|
|
@@ -7131,13 +7078,6 @@ describe("$compile", () => {
|
|
|
7131
7078
|
});
|
|
7132
7079
|
|
|
7133
7080
|
describe("scope()/isolate() scope getters", () => {
|
|
7134
|
-
describe("with no directives", () => {
|
|
7135
|
-
it("should return the scope of the parent node", () => {
|
|
7136
|
-
element = $compile("<div></div>")($rootScope);
|
|
7137
|
-
expect(element.scope()).toBe($rootScope);
|
|
7138
|
-
});
|
|
7139
|
-
});
|
|
7140
|
-
|
|
7141
7081
|
describe("with new scope directives", () => {
|
|
7142
7082
|
it("should return the new scope at the directive element", () => {
|
|
7143
7083
|
element = $compile("<div scope></div>")($rootScope);
|
|
@@ -7163,22 +7103,17 @@ describe("$compile", () => {
|
|
|
7163
7103
|
});
|
|
7164
7104
|
|
|
7165
7105
|
describe("with isolate scope directives", () => {
|
|
7166
|
-
it("should return the root scope for directives at the root element", () => {
|
|
7167
|
-
element = $compile("<div iscope></div>")($rootScope);
|
|
7168
|
-
expect(element.scope()).toBe($rootScope);
|
|
7169
|
-
});
|
|
7170
|
-
|
|
7171
7106
|
it("should return the non-isolate scope at the directive element", () => {
|
|
7107
|
+
expect($rootScope.$$childHead).toBeNull();
|
|
7172
7108
|
let directiveElement;
|
|
7173
7109
|
element = $compile("<div><div iscope></div></div>")($rootScope);
|
|
7174
7110
|
directiveElement = element.children();
|
|
7175
|
-
expect(
|
|
7176
|
-
expect(directiveElement.isolateScope().$parent).toBe($rootScope);
|
|
7111
|
+
expect($rootScope.$$childHead.$parent).toBe($rootScope);
|
|
7177
7112
|
});
|
|
7178
7113
|
|
|
7179
7114
|
it("should return the isolate scope for children in the original template", () => {
|
|
7180
7115
|
element = $compile("<div iscope><a></a></div>")($rootScope);
|
|
7181
|
-
expect(
|
|
7116
|
+
expect($rootScope.$$childHead.$parent).toBe($rootScope); // xx
|
|
7182
7117
|
});
|
|
7183
7118
|
|
|
7184
7119
|
it("should return the isolate scope for children in directive template", () => {
|
|
@@ -12193,7 +12128,7 @@ describe("$compile", () => {
|
|
|
12193
12128
|
if (element.parent().length) {
|
|
12194
12129
|
expect(expectedController).toBeDefined();
|
|
12195
12130
|
expect(controller).toBe(expectedController);
|
|
12196
|
-
expect(controller.foo).
|
|
12131
|
+
expect(controller.foo).toEqual("bar");
|
|
12197
12132
|
log.push("done");
|
|
12198
12133
|
}
|
|
12199
12134
|
},
|
|
@@ -13597,19 +13532,19 @@ describe("$compile", () => {
|
|
|
13597
13532
|
element = $compile(
|
|
13598
13533
|
'<div><div ng-repeat="x in xs" ng-if="x==1">{{x}}</div></div>',
|
|
13599
13534
|
)($rootScope);
|
|
13600
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13535
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13601
13536
|
|
|
13602
13537
|
$rootScope.$apply("xs = [0,1]");
|
|
13603
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13538
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13604
13539
|
|
|
13605
13540
|
$rootScope.$apply("xs = [0]");
|
|
13606
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13541
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13607
13542
|
|
|
13608
13543
|
$rootScope.$apply("xs = []");
|
|
13609
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13544
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13610
13545
|
|
|
13611
13546
|
element.remove();
|
|
13612
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13547
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13613
13548
|
});
|
|
13614
13549
|
|
|
13615
13550
|
it('should not leak if two "element" transclusions are on the same element', () => {
|
|
@@ -13621,20 +13556,20 @@ describe("$compile", () => {
|
|
|
13621
13556
|
$rootScope.$apply("xs = [0,1]");
|
|
13622
13557
|
// At this point we have a bunch of comment placeholders but no real transcluded elements
|
|
13623
13558
|
// So the cache only contains the root element's data
|
|
13624
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13559
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13625
13560
|
|
|
13626
13561
|
$rootScope.$apply("val = true");
|
|
13627
13562
|
// Now we have two concrete transcluded elements plus some comments so two more cache items
|
|
13628
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13563
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13629
13564
|
|
|
13630
13565
|
$rootScope.$apply("val = false");
|
|
13631
13566
|
// Once again we only have comments so no transcluded elements and the cache is back to just
|
|
13632
13567
|
// the root element
|
|
13633
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13568
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13634
13569
|
|
|
13635
13570
|
element.remove();
|
|
13636
13571
|
// Now we've even removed the root element along with its cache
|
|
13637
|
-
expect(CACHE.size).toEqual(cacheSize
|
|
13572
|
+
expect(CACHE.size).toEqual(cacheSize);
|
|
13638
13573
|
});
|
|
13639
13574
|
|
|
13640
13575
|
// it("should not leak when continuing the compilation of elements on a scope that was destroyed", () => {
|
|
@@ -13681,7 +13616,6 @@ describe("$compile", () => {
|
|
|
13681
13616
|
// destroyedScope.$destroy();
|
|
13682
13617
|
// const clone = template(destroyedScope, () => {});
|
|
13683
13618
|
// $rootScope.$digest();
|
|
13684
|
-
// debugger
|
|
13685
13619
|
// // expect(linkFn).not.toHaveBeenCalled();
|
|
13686
13620
|
// // clone.remove();
|
|
13687
13621
|
// });
|
|
@@ -13704,7 +13638,6 @@ describe("$compile", () => {
|
|
|
13704
13638
|
$rootScope.$apply(`xs = [${xs}]`);
|
|
13705
13639
|
firstRepeatedElem = element.children(".ng-scope").eq(0);
|
|
13706
13640
|
|
|
13707
|
-
expect(firstRepeatedElem.data("$scope")).toBeDefined();
|
|
13708
13641
|
privateData = CACHE.get(firstRepeatedElem[0][EXPANDO]);
|
|
13709
13642
|
expect(privateData.events).toBeDefined();
|
|
13710
13643
|
|
|
@@ -17083,40 +17016,39 @@ describe("$compile", () => {
|
|
|
17083
17016
|
"</div>",
|
|
17084
17017
|
)($rootScope);
|
|
17085
17018
|
$rootScope.$apply("val0 = true; val1 = true; val2 = true");
|
|
17086
|
-
|
|
17019
|
+
expect($rootScope.$$childHead).toBeTruthy();
|
|
17020
|
+
expect($rootScope.$$childHead.$$childHead).toBeTruthy();
|
|
17087
17021
|
// At this point we should have something like:
|
|
17088
17022
|
//
|
|
17089
17023
|
// <div>
|
|
17090
17024
|
//
|
|
17091
|
-
//
|
|
17092
|
-
//
|
|
17025
|
+
// <!---->
|
|
17093
17026
|
// <div ng-if-start="val0">
|
|
17094
|
-
//
|
|
17027
|
+
// <!---->
|
|
17095
17028
|
// <span ng-if="val1"></span>
|
|
17096
|
-
//
|
|
17029
|
+
// <!---->
|
|
17097
17030
|
// </div>
|
|
17098
17031
|
//
|
|
17099
17032
|
// <div ng-if-end="">
|
|
17100
|
-
//
|
|
17033
|
+
// <!---->
|
|
17101
17034
|
// <span ng-if="val2"></span>
|
|
17102
|
-
//
|
|
17035
|
+
// <!---->
|
|
17103
17036
|
// </div>
|
|
17104
17037
|
//
|
|
17105
|
-
//
|
|
17038
|
+
// <!---->
|
|
17106
17039
|
// </div>
|
|
17107
|
-
const ngIfStartScope = element.find("div").eq(0).scope();
|
|
17108
|
-
const ngIfEndScope = element.find("div").eq(1).scope();
|
|
17040
|
+
// const ngIfStartScope = element.find("div").eq(0).scope();
|
|
17041
|
+
// const ngIfEndScope = element.find("div").eq(1).scope();
|
|
17109
17042
|
|
|
17110
|
-
expect(ngIfStartScope.$id).toEqual(ngIfEndScope.$id);
|
|
17043
|
+
// expect(ngIfStartScope.$id).toEqual(ngIfEndScope.$id);
|
|
17111
17044
|
|
|
17112
|
-
const ngIf1Scope = element.find("span").eq(0).scope();
|
|
17113
|
-
const ngIf2Scope = element.find("span").eq(1).scope();
|
|
17045
|
+
// const ngIf1Scope = element.find("span").eq(0).scope();
|
|
17046
|
+
// const ngIf2Scope = element.find("span").eq(1).scope();
|
|
17114
17047
|
|
|
17115
|
-
expect(ngIf1Scope.$id).not.toEqual(ngIf2Scope.$id);
|
|
17116
|
-
expect(ngIf1Scope.$parent.$id).toEqual(ngIf2Scope.$parent.$id);
|
|
17048
|
+
// expect(ngIf1Scope.$id).not.toEqual(ngIf2Scope.$id);
|
|
17049
|
+
// expect(ngIf1Scope.$parent.$id).toEqual(ngIf2Scope.$parent.$id);
|
|
17117
17050
|
|
|
17118
17051
|
$rootScope.$apply("val1 = false");
|
|
17119
|
-
|
|
17120
17052
|
// Now we should have something like:
|
|
17121
17053
|
//
|
|
17122
17054
|
// <div>
|
|
@@ -17132,9 +17064,9 @@ describe("$compile", () => {
|
|
|
17132
17064
|
// <!-- end ngIf: val0 -->
|
|
17133
17065
|
// </div>
|
|
17134
17066
|
|
|
17135
|
-
expect(ngIfStartScope.$$destroyed).not.toEqual(true);
|
|
17136
|
-
expect(ngIf1Scope.$$destroyed).toEqual(true);
|
|
17137
|
-
expect(ngIf2Scope.$$destroyed).not.toEqual(true);
|
|
17067
|
+
// expect(ngIfStartScope.$$destroyed).not.toEqual(true);
|
|
17068
|
+
// expect(ngIf1Scope.$$destroyed).toEqual(true);
|
|
17069
|
+
// expect(ngIf2Scope.$$destroyed).not.toEqual(true);
|
|
17138
17070
|
|
|
17139
17071
|
$rootScope.$apply("val0 = false");
|
|
17140
17072
|
|
|
@@ -17143,10 +17075,11 @@ describe("$compile", () => {
|
|
|
17143
17075
|
// <div>
|
|
17144
17076
|
// <!-- ngIf: val0 -->
|
|
17145
17077
|
// </div>
|
|
17146
|
-
|
|
17147
|
-
expect(
|
|
17148
|
-
expect(
|
|
17149
|
-
expect(
|
|
17078
|
+
// TODO: Until we figure out a better way of testing this
|
|
17079
|
+
expect($rootScope.$$childHead).toBeNull();
|
|
17080
|
+
// expect(ngIfStartScope.$$destroyed).toEqual(true);
|
|
17081
|
+
// expect(ngIf1Scope.$$destroyed).toEqual(true);
|
|
17082
|
+
// expect(ngIf2Scope.$$destroyed).toEqual(true);
|
|
17150
17083
|
});
|
|
17151
17084
|
|
|
17152
17085
|
it("should set up and destroy the transclusion scopes correctly", () => {
|
|
@@ -17162,7 +17095,7 @@ describe("$compile", () => {
|
|
|
17162
17095
|
// <!-- ngRepeat: val in val0 -->
|
|
17163
17096
|
// </div>
|
|
17164
17097
|
|
|
17165
|
-
expect(element.scope().$id).toEqual($rootScope.$id);
|
|
17098
|
+
//expect(element.scope().$id).toEqual($rootScope.$id);
|
|
17166
17099
|
|
|
17167
17100
|
// Now we create all the elements
|
|
17168
17101
|
$rootScope.$apply("val0 = [1]; val1 = true; val2 = true");
|
|
@@ -17183,17 +17116,17 @@ describe("$compile", () => {
|
|
|
17183
17116
|
// <!-- end ngIf: val2 -->
|
|
17184
17117
|
// <!-- end ngRepeat: val in val0 -->
|
|
17185
17118
|
// </div>
|
|
17186
|
-
const ngIf1Scope = element.find("div").eq(0).scope();
|
|
17187
|
-
const ngIf2Scope = element.find("div").eq(1).scope();
|
|
17188
|
-
const ngRepeatScope = ngIf1Scope.$parent;
|
|
17119
|
+
// const ngIf1Scope = element.find("div").eq(0).scope();
|
|
17120
|
+
// const ngIf2Scope = element.find("div").eq(1).scope();
|
|
17121
|
+
// const ngRepeatScope = ngIf1Scope.$parent;
|
|
17189
17122
|
|
|
17190
|
-
expect(ngIf1Scope.$id).not.toEqual(ngIf2Scope.$id);
|
|
17191
|
-
expect(ngIf1Scope.$parent.$id).toEqual(ngRepeatScope.$id);
|
|
17192
|
-
expect(ngIf2Scope.$parent.$id).toEqual(ngRepeatScope.$id);
|
|
17123
|
+
// expect(ngIf1Scope.$id).not.toEqual(ngIf2Scope.$id);
|
|
17124
|
+
// expect(ngIf1Scope.$parent.$id).toEqual(ngRepeatScope.$id);
|
|
17125
|
+
// expect(ngIf2Scope.$parent.$id).toEqual(ngRepeatScope.$id);
|
|
17193
17126
|
|
|
17194
|
-
// What is happening here??
|
|
17195
|
-
// We seem to have a repeater scope which doesn't actually match to any element
|
|
17196
|
-
expect(ngRepeatScope.$parent.$id).toEqual($rootScope.$id);
|
|
17127
|
+
// // What is happening here??
|
|
17128
|
+
// // We seem to have a repeater scope which doesn't actually match to any element
|
|
17129
|
+
// expect(ngRepeatScope.$parent.$id).toEqual($rootScope.$id);
|
|
17197
17130
|
|
|
17198
17131
|
// Now remove the first ngIf element from the first item in the repeater
|
|
17199
17132
|
$rootScope.$apply("val1 = false");
|
|
@@ -17212,9 +17145,9 @@ describe("$compile", () => {
|
|
|
17212
17145
|
// <!-- end ngRepeat: val in val0 -->
|
|
17213
17146
|
// </div>
|
|
17214
17147
|
//
|
|
17215
|
-
expect(ngRepeatScope.$$destroyed).toEqual(false);
|
|
17216
|
-
expect(ngIf1Scope.$$destroyed).toEqual(true);
|
|
17217
|
-
expect(ngIf2Scope.$$destroyed).toEqual(false);
|
|
17148
|
+
// expect(ngRepeatScope.$$destroyed).toEqual(false);
|
|
17149
|
+
// expect(ngIf1Scope.$$destroyed).toEqual(true);
|
|
17150
|
+
// expect(ngIf2Scope.$$destroyed).toEqual(false);
|
|
17218
17151
|
|
|
17219
17152
|
// Now remove the second ngIf element from the first item in the repeater
|
|
17220
17153
|
$rootScope.$apply("val2 = false");
|
|
@@ -17228,17 +17161,18 @@ describe("$compile", () => {
|
|
|
17228
17161
|
// <!-- end ngRepeat: val in val0 -->
|
|
17229
17162
|
// </div>
|
|
17230
17163
|
|
|
17231
|
-
expect(ngRepeatScope.$$destroyed).toEqual(false);
|
|
17232
|
-
expect(ngIf1Scope.$$destroyed).toEqual(true);
|
|
17233
|
-
expect(ngIf2Scope.$$destroyed).toEqual(true);
|
|
17164
|
+
// expect(ngRepeatScope.$$destroyed).toEqual(false);
|
|
17165
|
+
// expect(ngIf1Scope.$$destroyed).toEqual(true);
|
|
17166
|
+
// expect(ngIf2Scope.$$destroyed).toEqual(true);
|
|
17234
17167
|
|
|
17235
17168
|
// Finally remove the repeat items
|
|
17236
17169
|
$rootScope.$apply("val0 = []");
|
|
17237
17170
|
|
|
17238
17171
|
// Somehow this ngRepeat scope knows how to destroy itself...
|
|
17239
|
-
expect(
|
|
17240
|
-
expect(
|
|
17241
|
-
expect(
|
|
17172
|
+
expect($rootScope.$$childHead).toBeNull();
|
|
17173
|
+
// expect(ngRepeatScope.$$destroyed).toEqual(true);
|
|
17174
|
+
// expect(ngIf1Scope.$$destroyed).toEqual(true);
|
|
17175
|
+
// expect(ngIf2Scope.$$destroyed).toEqual(true);
|
|
17242
17176
|
});
|
|
17243
17177
|
|
|
17244
17178
|
it("should throw error if unterminated", () => {
|
|
@@ -17734,26 +17668,4 @@ describe("$compile", () => {
|
|
|
17734
17668
|
);
|
|
17735
17669
|
});
|
|
17736
17670
|
});
|
|
17737
|
-
|
|
17738
|
-
describe("$$createComment", () => {
|
|
17739
|
-
it("should create empty comments if `debugInfoEnabled` is false", () => {
|
|
17740
|
-
module.config(($compileProvider) => {
|
|
17741
|
-
$compileProvider.debugInfoEnabled(false);
|
|
17742
|
-
});
|
|
17743
|
-
initInjector("test1");
|
|
17744
|
-
|
|
17745
|
-
const comment = $compile.$$createComment("foo", "bar");
|
|
17746
|
-
expect(comment.data).toBe("");
|
|
17747
|
-
});
|
|
17748
|
-
|
|
17749
|
-
it("should create descriptive comments if `debugInfoEnabled` is true", () => {
|
|
17750
|
-
module.config(($compileProvider) => {
|
|
17751
|
-
$compileProvider.debugInfoEnabled(true);
|
|
17752
|
-
});
|
|
17753
|
-
|
|
17754
|
-
initInjector("test1");
|
|
17755
|
-
const comment = $compile.$$createComment("foo", "bar");
|
|
17756
|
-
expect(comment.data).toBe(" foo: bar ");
|
|
17757
|
-
});
|
|
17758
|
-
});
|
|
17759
17671
|
});
|