@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.
@@ -103,10 +103,11 @@ describe("ngIf", () => {
103
103
 
104
104
  it("should destroy the child scope every time the expression evaluates to false", () => {
105
105
  $scope.value = true;
106
+ debugger;
106
107
  element.append($compile('<div ng-if="value"></div>')($scope));
107
108
  $scope.$apply();
108
109
 
109
- const childScope = element.children().scope();
110
+ const childScope = $scope.$$childHead;
110
111
  let destroyed = false;
111
112
 
112
113
  childScope.$on("$destroy", () => {
@@ -236,13 +236,13 @@ describe("ngInclude", () => {
236
236
  const injector = angular.bootstrap(element, ["myModule"]);
237
237
  $rootScope = injector.get("$rootScope");
238
238
  $rootScope.$digest();
239
- expect(element.children().scope()).toBeFalsy();
239
+ expect($rootScope.$$childHead).toBeFalsy();
240
240
 
241
241
  $rootScope.url = "/mock/hello";
242
242
  $rootScope.$digest();
243
243
 
244
244
  setTimeout(() => {
245
- expect(element.children().scope().$parent).toBe($rootScope);
245
+ expect($rootScope.$$childHead.$parent).toBe($rootScope);
246
246
  expect(element.text()).toBe("Hello");
247
247
 
248
248
  $rootScope.url = "/mock/401";
@@ -258,7 +258,7 @@ describe("ngInclude", () => {
258
258
  }, 200);
259
259
 
260
260
  setTimeout(() => {
261
- expect(element.children().scope().$parent).toBe($rootScope);
261
+ expect($rootScope.$$childHead.$parent).toBe($rootScope);
262
262
 
263
263
  $rootScope.url = null;
264
264
  $rootScope.$digest();
@@ -1076,43 +1076,6 @@ describe("ngRepeat", () => {
1076
1076
  }, 300);
1077
1077
  });
1078
1078
 
1079
- it("should add separator comments after each item", () => {
1080
- const check = function () {
1081
- const children = element.find("div");
1082
- expect(children.length).toBe(3);
1083
-
1084
- // Note: COMMENT_NODE === 8
1085
- expect(children[0].nextSibling.nodeType).toBe(8);
1086
- expect(children[0].nextSibling.nodeValue).toBe(
1087
- " end ngRepeat: val in values ",
1088
- );
1089
- expect(children[1].nextSibling.nodeType).toBe(8);
1090
- expect(children[1].nextSibling.nodeValue).toBe(
1091
- " end ngRepeat: val in values ",
1092
- );
1093
- expect(children[2].nextSibling.nodeType).toBe(8);
1094
- expect(children[2].nextSibling.nodeValue).toBe(
1095
- " end ngRepeat: val in values ",
1096
- );
1097
- };
1098
-
1099
- scope.values = [1, 2, 3];
1100
-
1101
- element = $compile(
1102
- "<div>" +
1103
- '<div ng-repeat="val in values">val:{{val}};</div>' +
1104
- "</div>",
1105
- )(scope);
1106
-
1107
- scope.$digest();
1108
- check();
1109
-
1110
- scope.values.shift();
1111
- scope.values.push(4);
1112
- scope.$digest();
1113
- check();
1114
- });
1115
-
1116
1079
  it("should remove whole block even if the number of elements inside it changes", () => {
1117
1080
  scope.values = [1, 2, 3];
1118
1081
 
@@ -29,9 +29,7 @@ describe("ngSwitch", () => {
29
29
  '<div ng-switch-when="true">true:{{name}}</div>' +
30
30
  "</div>",
31
31
  )($scope);
32
- expect(element[0].innerHTML).toEqual(
33
- "<!-- ngSwitchWhen: 1 --><!-- ngSwitchWhen: 2 --><!-- ngSwitchWhen: true -->",
34
- );
32
+ expect(element[0].innerHTML).toEqual("<!----><!----><!---->");
35
33
  $scope.select = 1;
36
34
  $scope.$apply();
37
35
  expect(element.text()).toEqual("first:");
@@ -58,12 +56,7 @@ describe("ngSwitch", () => {
58
56
  '<li ng-switch-when="true">true:{{name}}</li>' +
59
57
  "</ul>",
60
58
  )($scope);
61
- expect(element[0].innerHTML).toEqual(
62
- "<!-- ngSwitchWhen: 1 -->" +
63
- "<!-- ngSwitchWhen: 1 -->" +
64
- "<!-- ngSwitchWhen: 2 -->" +
65
- "<!-- ngSwitchWhen: true -->",
66
- );
59
+ expect(element[0].innerHTML).toEqual("<!----><!----><!----><!---->");
67
60
  $scope.select = 1;
68
61
  $scope.$apply();
69
62
  expect(element.text()).toEqual("first:, first too:");
@@ -230,32 +223,29 @@ describe("ngSwitch", () => {
230
223
 
231
224
  it("should properly create and destroy child scopes", () => {
232
225
  element = $compile(
233
- '<ng:switch on="url">' +
234
- '<div ng-switch-when="a">{{name}}</div>' +
235
- "</ng:switch>",
226
+ '<ng-switch on="url"><div ng-switch-when="a">{{name}}</div></ng-switch>',
236
227
  )($scope);
237
228
  $scope.$apply();
238
229
 
239
- const getChildScope = function () {
240
- return element.find("div").scope();
241
- };
242
-
243
- expect(getChildScope()).toBeUndefined();
230
+ expect($scope.$$childHead).toBeNull();
244
231
 
245
232
  $scope.url = "a";
246
233
  $scope.$apply();
247
- const child1 = getChildScope();
234
+ const child1 = $scope.$$childHead;
248
235
  expect(child1).toBeDefined();
249
236
  spyOn(child1, "$destroy");
250
237
 
251
238
  $scope.url = "x";
252
239
  $scope.$apply();
253
- expect(getChildScope()).toBeUndefined();
240
+
241
+ // NOTE THAT THE CHILD SCOPE IS NOT ACTUALLY DESTROYED.
242
+ expect(child1).toBeDefined();
254
243
  expect(child1.$destroy).toHaveBeenCalled();
255
244
 
256
245
  $scope.url = "a";
257
246
  $scope.$apply();
258
- const child2 = getChildScope();
247
+ // ... BUT A NEW CHILD SCOPE WILL BE CREATED IN A TAIL.
248
+ const child2 = $scope.$$childTail;
259
249
  expect(child2).toBeDefined();
260
250
  expect(child2).not.toBe(child1);
261
251
  });
package/types/jqlite.d.ts CHANGED
@@ -56,30 +56,6 @@ interface JQLite {
56
56
  */
57
57
  attr(attributes: Object): this;
58
58
 
59
- /**
60
- * Attach a handler to an event for the elements.
61
- *
62
- * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
63
- * @param handler A function to execute each time the event is triggered.
64
- * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-handler}
65
- */
66
- bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): this;
67
- /**
68
- * Attach a handler to an event for the elements.
69
- *
70
- * @param eventType A string containing one or more DOM event types, such as "click" or "submit," or custom event names.
71
- * @param preventBubble Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling. The default is true.
72
- * @see {@link https://api.jquery.com/bind/#bind-eventType-eventData-preventBubble}
73
- */
74
- bind(eventType: string, preventBubble: boolean): this;
75
- /**
76
- * Attach a handler to an event for the elements.
77
- *
78
- * @param events An object containing one or more DOM event types and functions to execute for them.
79
- * @see {@link https://api.jquery.com/bind/#bind-events}
80
- */
81
- bind(events: any): this;
82
-
83
59
  /**
84
60
  * Get the children of each element in the set of matched elements, optionally filtered by a selector.
85
61
  *
@@ -276,60 +252,6 @@ interface JQLite {
276
252
  */
277
253
  off(events: { [key: string]: any }, selector?: string): this;
278
254
 
279
- /**
280
- * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
281
- *
282
- * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
283
- * @param handler A function to execute at the time the event is triggered.
284
- * @see {@link https://api.jquery.com/one/#one-events-data-handler}
285
- */
286
- one(events: string, handler: (eventObject: JQueryEventObject) => any): this;
287
- /**
288
- * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
289
- *
290
- * @param events A string containing one or more JavaScript event types, such as "click" or "submit," or custom event names.
291
- * @param data An object containing data that will be passed to the event handler.
292
- * @param handler A function to execute at the time the event is triggered.
293
- * @see {@link https://api.jquery.com/one/#one-events-data-handler}
294
- */
295
- one(events: string, data: Object, handler: (eventObject: JQueryEventObject) => any): this;
296
- /**
297
- * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
298
- *
299
- * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
300
- * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
301
- * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
302
- * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler}
303
- */
304
- one(events: string, selector: string, handler: (eventObject: JQueryEventObject) => any): this;
305
- /**
306
- * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
307
- *
308
- * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
309
- * @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
310
- * @param data Data to be passed to the handler in event.data when an event is triggered.
311
- * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
312
- * @see {@link https://api.jquery.com/one/#one-events-selector-data-handler}
313
- */
314
- one(events: string, selector: string, data: any, handler: (eventObject: JQueryEventObject) => any): this;
315
- /**
316
- * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
317
- *
318
- * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s).
319
- * @param selector A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element.
320
- * @param data Data to be passed to the handler in event.data when an event occurs.
321
- * @see {@link https://api.jquery.com/one/#one-events-selector-data}
322
- */
323
- one(events: { [key: string]: any }, selector?: string, data?: any): this;
324
- /**
325
- * Attach a handler to an event for the elements. The handler is executed at most once per element per event type.
326
- *
327
- * @param events An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s).
328
- * @param data Data to be passed to the handler in event.data when an event occurs.
329
- * @see {@link https://api.jquery.com/one/#one-events-selector-data}
330
- */
331
- one(events: { [key: string]: any }, data?: any): this;
332
-
333
255
  /**
334
256
  * Get the parent of each element in the current set of matched elements, optionally filtered by a selector.
335
257
  *