Skip to content

Commit 43ce62b

Browse files
committed
Remove and
1 parent 4ec38e2 commit 43ce62b

File tree

4 files changed

+37
-51
lines changed

4 files changed

+37
-51
lines changed

@types/core/scope/scope.d.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ export class Scope {
146146
): any;
147147
propertyMap: {
148148
$watch: any;
149-
$watchGroup: any;
150-
$watchCollection: any;
151149
$new: any;
152150
$newIsolate: any;
153151
$destroy: any;
@@ -191,14 +189,13 @@ export class Scope {
191189
listenerFn?: ListenerFunction,
192190
lazy?: boolean,
193191
): () => void;
194-
$watchGroup(watchArray: any, listenerFn: any): void;
195-
$watchCollection(watchProp: any, listenerFn: any): () => void;
196192
$new(childInstance: any): any;
197193
$newIsolate(instance: any): any;
198194
$transcluded(parentInstance: any): any;
199-
registerKey(key: any, listener: any): void;
200-
registerForeignKey(key: any, listener: any): void;
201-
deregisterKey(key: any, id: any): boolean;
195+
/**
196+
* @private
197+
*/
198+
private deregisterKey;
202199
deregisterForeignKey(key: any, id: any): boolean;
203200
$eval(expr: any, locals: any): any;
204201
$evalAsync(expr: any, locals: any): Promise<any>;
@@ -242,18 +239,19 @@ export class Scope {
242239
$postUpdate(fn: any): void;
243240
$destroy(): void;
244241
/**
245-
* Invokes the registered listener function with watched property changes.
242+
* @private
246243
*
247244
* @param {Listener} listener - The property path that was changed.
248245
*/
249-
notifyListener(listener: Listener, target: any): void;
246+
private notifyListener;
250247
/**
251248
* Searches the scope instance
252249
*
253250
* @param {string|number}id
254251
* @returns {Scope|undefined}
255252
*/
256253
$getById(id: string | number): Scope | undefined;
254+
#private;
257255
}
258256
export type AsyncQueueTask = {
259257
handler: Scope;

src/animations/animate-swap.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,22 @@ export function ngAnimateSwapDirective($animate) {
1212
link(scope, $element, attrs, ctrl, $transclude) {
1313
let previousElement;
1414
let previousScope;
15-
scope.$watchCollection(
16-
attrs["ngAnimateSwap"] || attrs["for"],
17-
(value) => {
18-
if (previousElement) {
19-
$animate.leave(previousElement);
20-
}
21-
if (previousScope) {
22-
previousScope.$destroy();
23-
previousScope = null;
24-
}
25-
if (value) {
26-
$transclude((clone, childScope) => {
27-
previousElement = clone;
28-
previousScope = childScope;
29-
$animate.enter(clone, null, $element);
30-
});
31-
}
32-
},
33-
);
15+
scope.$watch(attrs["ngAnimateSwap"] || attrs["for"], (value) => {
16+
if (previousElement) {
17+
$animate.leave(previousElement);
18+
}
19+
if (previousScope) {
20+
previousScope.$destroy();
21+
previousScope = null;
22+
}
23+
if (value) {
24+
$transclude((clone, childScope) => {
25+
previousElement = clone;
26+
previousScope = childScope;
27+
$animate.enter(clone, null, $element);
28+
});
29+
}
30+
});
3431
},
3532
};
3633
}

src/core/scope/scope.js

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,6 @@ export class Scope {
478478

479479
this.propertyMap = {
480480
$watch: this.$watch.bind(this),
481-
$watchGroup: this.$watchGroup.bind(this),
482-
$watchCollection: this.$watchCollection.bind(this),
483481
$new: this.$new.bind(this),
484482
$newIsolate: this.$newIsolate.bind(this),
485483
$destroy: this.$destroy.bind(this),
@@ -499,7 +497,7 @@ export class Scope {
499497
$root: this.$root,
500498
$children: this.$children,
501499
$id: this.$id,
502-
registerForeignKey: this.registerForeignKey.bind(this),
500+
registerForeignKey: this.#registerForeignKey.bind(this),
503501
notifyListener: this.notifyListener.bind(this),
504502
$merge: this.$merge.bind(this),
505503
$getById: this.$getById.bind(this),
@@ -675,7 +673,7 @@ export class Scope {
675673
keys.push(get.decoratedNode.body[0].expression.left.toWatch[0]?.name);
676674
keys.push(get.decoratedNode.body[0].expression.right.toWatch[0]?.name);
677675
keys.forEach((key) => {
678-
this.registerKey(key, listener);
676+
this.#registerKey(key, listener);
679677
});
680678
return () => {
681679
keys.forEach((key) => {
@@ -716,7 +714,7 @@ export class Scope {
716714
}
717715
});
718716
keys.forEach((key) => {
719-
this.registerKey(key, listener);
717+
this.#registerKey(key, listener);
720718
this.scheduleListener([listener]);
721719
});
722720

@@ -745,7 +743,7 @@ export class Scope {
745743
watchProp.split(".").slice(0, -1).join("."),
746744
)(listener.originalTarget);
747745
if (potentialProxy && this.foreignProxies.has(potentialProxy)) {
748-
potentialProxy.$handler.registerForeignKey(key, listener);
746+
potentialProxy.$handler.#registerForeignKey(key, listener);
749747
potentialProxy.$handler.scheduleListener([listener]);
750748
return () => {
751749
return potentialProxy.$handler.deregisterKey(key, listener.id);
@@ -779,7 +777,7 @@ export class Scope {
779777
})
780778
.filter((x) => !!x);
781779
keys.forEach((key) => {
782-
this.registerKey(key, listener);
780+
this.#registerKey(key, listener);
783781
this.scheduleListener([listener]);
784782
});
785783
return () => {
@@ -846,10 +844,10 @@ export class Scope {
846844

847845
if (keySet.length > 0) {
848846
keySet.forEach((key) => {
849-
this.registerKey(key, listener);
847+
this.#registerKey(key, listener);
850848
});
851849
} else {
852-
this.registerKey(key, listener);
850+
this.#registerKey(key, listener);
853851
}
854852

855853
if (!lazy) {
@@ -871,14 +869,6 @@ export class Scope {
871869
};
872870
}
873871

874-
$watchGroup(watchArray, listenerFn) {
875-
watchArray.forEach((x) => this.$watch(x, listenerFn));
876-
}
877-
878-
$watchCollection(watchProp, listenerFn) {
879-
return this.$watch(watchProp, listenerFn);
880-
}
881-
882872
$new(childInstance) {
883873
let child;
884874
if (childInstance) {
@@ -908,7 +898,6 @@ export class Scope {
908898

909899
$newIsolate(instance) {
910900
let child = instance ? Object.create(instance) : Object.create(null);
911-
// child.$root = this.$root;
912901
const proxy = new Proxy(child, new Scope(this, this.$root));
913902
this.$children.push(proxy);
914903
return proxy;
@@ -921,22 +910,24 @@ export class Scope {
921910
return proxy;
922911
}
923912

924-
registerKey(key, listener) {
913+
#registerKey(key, listener) {
925914
if (this.watchers.has(key)) {
926915
this.watchers.get(key).push(listener);
927916
} else {
928917
this.watchers.set(key, [listener]);
929918
}
930919
}
931920

932-
registerForeignKey(key, listener) {
921+
#registerForeignKey(key, listener) {
933922
if (this.foreignListeners.has(key)) {
934923
this.foreignListeners.get(key).push(listener);
935924
} else {
936925
this.foreignListeners.set(key, [listener]);
937926
}
938927
}
939-
928+
/**
929+
* @private
930+
*/
940931
deregisterKey(key, id) {
941932
const listenerList = this.watchers.get(key);
942933
if (!listenerList) return false;
@@ -1182,7 +1173,7 @@ export class Scope {
11821173
}
11831174

11841175
/**
1185-
* Invokes the registered listener function with watched property changes.
1176+
* @private
11861177
*
11871178
* @param {Listener} listener - The property path that was changed.
11881179
*/

src/directive/messages/messages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NgMessageCtrl {
2525
this.head = undefined;
2626
this.default = undefined;
2727

28-
this.$scope.$watchCollection(
28+
this.$scope.$watch(
2929
this.$attrs["ngMessages"] || this.$attrs["for"],
3030
this.render.bind(this),
3131
);

0 commit comments

Comments
 (0)