1
- import {
2
- ChangeDetector ,
3
- ChangeDetectorGroup ,
4
- ChangeRecord ,
5
- MapChangeRecord ,
6
- MapKeyValue ,
7
- CollectionChangeRecord ,
8
- CollectionChangeItem
9
- } from './change_detection' ;
10
1
/**
11
2
* these cannot currently be defined in the DirtyCheckingRecord class itself,
12
3
* unfortunately. They've been moved outside and de-const-ified for this
@@ -15,6 +6,7 @@ import {
15
6
var _MODE_NAMES = [
16
7
'MARKER' , 'IDENT' , 'REFLECT' , 'GETTER' , 'MAP[]' , 'ITERABLE' , 'MAP'
17
8
] ;
9
+
18
10
var _MODE_MARKER_ = 0 ;
19
11
var _MODE_IDENTITY_ = 1 ;
20
12
var _MODE_REFLECT_ = 2 ;
@@ -34,7 +26,7 @@ export class GetterCache {
34
26
}
35
27
}
36
28
37
- export class DirtyCheckingChangeDetectorGroup extends ChangeDetector {
29
+ export class DirtyCheckingChangeDetectorGroup {
38
30
constructor ( parent , cache ) {
39
31
this . _parent = parent ;
40
32
this . _getterCache = cache ;
@@ -286,7 +278,7 @@ class ChangeIterator {
286
278
}
287
279
}
288
280
289
- class DirtyCheckingRecord extends ChangeRecord {
281
+ class DirtyCheckingRecord {
290
282
constructor ( group , object , fieldName , getter , handler ) {
291
283
this . _group = group ;
292
284
this . _getter = getter ;
@@ -341,12 +333,12 @@ class DirtyCheckingRecord extends ChangeRecord {
341
333
if ( this . _mode !== _MODE_ITERABLE_ ) {
342
334
// Last one was collection as well, don't reset state.
343
335
this . _mode = _MODE_ITERABLE_ ;
344
- this . currentValue = new _CollectionChangeRecord ( ) ;
336
+ this . currentValue = new CollectionChangeRecord ( ) ;
345
337
}
346
338
} else if ( this . _mode !== _MODE_MAP_ ) {
347
339
// Last one was collection as well, don't reset state.
348
340
this . _mode = _MODE_MAP_ ;
349
- this . currentValue = new _MapChangeRecord ( ) ;
341
+ this . currentValue = new MapChangeRecord ( ) ;
350
342
}
351
343
} else {
352
344
this . _mode = _MODE_IDENTITY_ ;
@@ -439,7 +431,8 @@ class DirtyCheckingRecord extends ChangeRecord {
439
431
return `${ _MODE_NAMES [ this . _mode ] } [${ this . field } ]{${ hashCode } }` ;
440
432
}
441
433
}
442
- class _MapChangeRecord extends MapChangeRecord {
434
+
435
+ export class MapChangeRecord {
443
436
constructor ( ) {
444
437
this . _records = { } ; // WeakMap perhaps?
445
438
this . _map = { } ;
@@ -668,7 +661,8 @@ class _MapChangeRecord extends MapChangeRecord {
668
661
}
669
662
}
670
663
}
671
- class KeyValueRecord extends MapKeyValue {
664
+
665
+ class KeyValueRecord {
672
666
constructor ( key ) {
673
667
this . _key = key ;
674
668
this . _previousValue = this . _currentValue = null ;
@@ -702,7 +696,8 @@ class KeyValueRecord extends MapKeyValue {
702
696
: `${ this . _key } [${ this . _previousValue } -> ${ this . _currentValue } ]` ;
703
697
}
704
698
}
705
- class _CollectionChangeRecord extends CollectionChangeRecord {
699
+
700
+ export class CollectionChangeRecord {
706
701
constructor ( ) {
707
702
this . _iterable = null ;
708
703
this . _items = new DuplicateMap ( ) ;
@@ -827,7 +822,7 @@ class _CollectionChangeRecord extends CollectionChangeRecord {
827
822
// assert(isDirty == false);
828
823
}
829
824
/**
830
- * A [_CollectionChangeRecord ] is considered dirty if it has additions, moves
825
+ * A [CollectionChangeRecord ] is considered dirty if it has additions, moves
831
826
* or removals.
832
827
*/
833
828
get isDirty ( ) {
@@ -1087,7 +1082,8 @@ class _CollectionChangeRecord extends CollectionChangeRecord {
1087
1082
"removals: " + removals . join ( ', ' ) + "\n" ;
1088
1083
}
1089
1084
}
1090
- class ItemRecord extends CollectionChangeItem {
1085
+
1086
+ class ItemRecord {
1091
1087
constructor ( item ) {
1092
1088
this . item = item ;
1093
1089
this . previousIndex = this . currentIndex = null ;
@@ -1114,6 +1110,7 @@ class ItemRecord extends CollectionChangeItem {
1114
1110
: `${ this . item } [${ this . previousIndex } -> ${ this . currentIndex } ]` ;
1115
1111
}
1116
1112
}
1113
+
1117
1114
class _DuplicateItemRecordList {
1118
1115
constructor ( ) {
1119
1116
this . head = this . tail = null ;
@@ -1184,6 +1181,7 @@ class _DuplicateItemRecordList {
1184
1181
return this . head === null ;
1185
1182
}
1186
1183
}
1184
+
1187
1185
class DuplicateMap {
1188
1186
constructor ( ) {
1189
1187
// For an identical behaviour to the Dart implementation, a Map or WeakMap is required. However,
@@ -1217,4 +1215,4 @@ class DuplicateMap {
1217
1215
clear ( ) {
1218
1216
this . _map . clear ( ) ;
1219
1217
}
1220
- }
1218
+ }
0 commit comments