@@ -90,9 +90,8 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
90
90
var bindingRecord = proto . bindingRecord ;
91
91
var directiveRecord = bindingRecord . directiveRecord ;
92
92
93
- var change = this . _check ( proto ) ;
93
+ var change = this . _check ( proto , throwOnChange ) ;
94
94
if ( isPresent ( change ) ) {
95
- if ( throwOnChange ) ChangeDetectionUtil . throwOnChange ( proto , change ) ;
96
95
this . _updateDirectiveOrElement ( change , bindingRecord ) ;
97
96
isChanged = true ;
98
97
changes = this . _addChange ( bindingRecord , change , changes ) ;
@@ -144,19 +143,19 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
144
143
145
144
_getDetectorFor ( directiveIndex ) { return this . directives . getDetectorFor ( directiveIndex ) ; }
146
145
147
- _check ( proto : ProtoRecord ) : SimpleChange {
146
+ _check ( proto : ProtoRecord , throwOnChange : boolean ) : SimpleChange {
148
147
try {
149
148
if ( proto . mode === RECORD_TYPE_PIPE || proto . mode === RECORD_TYPE_BINDING_PIPE ) {
150
- return this . _pipeCheck ( proto ) ;
149
+ return this . _pipeCheck ( proto , throwOnChange ) ;
151
150
} else {
152
- return this . _referenceCheck ( proto ) ;
151
+ return this . _referenceCheck ( proto , throwOnChange ) ;
153
152
}
154
153
} catch ( e ) {
155
154
throw new ChangeDetectionError ( proto , e ) ;
156
155
}
157
156
}
158
157
159
- _referenceCheck ( proto : ProtoRecord ) {
158
+ _referenceCheck ( proto : ProtoRecord , throwOnChange : boolean ) {
160
159
if ( this . _pureFuncAndArgsDidNotChange ( proto ) ) {
161
160
this . _setChanged ( proto , false ) ;
162
161
return null ;
@@ -166,12 +165,18 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
166
165
var currValue = this . _calculateCurrValue ( proto ) ;
167
166
168
167
if ( ! isSame ( prevValue , currValue ) ) {
169
- this . _writeSelf ( proto , currValue ) ;
170
- this . _setChanged ( proto , true ) ;
171
-
172
168
if ( proto . lastInBinding ) {
173
- return ChangeDetectionUtil . simpleChange ( prevValue , currValue ) ;
169
+ var change = ChangeDetectionUtil . simpleChange ( prevValue , currValue ) ;
170
+ if ( throwOnChange ) ChangeDetectionUtil . throwOnChange ( proto , change ) ;
171
+
172
+ this . _writeSelf ( proto , currValue ) ;
173
+ this . _setChanged ( proto , true ) ;
174
+
175
+ return change ;
176
+
174
177
} else {
178
+ this . _writeSelf ( proto , currValue ) ;
179
+ this . _setChanged ( proto , true ) ;
175
180
return null ;
176
181
}
177
182
} else {
@@ -216,22 +221,28 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
216
221
}
217
222
}
218
223
219
- _pipeCheck ( proto : ProtoRecord ) {
224
+ _pipeCheck ( proto : ProtoRecord , throwOnChange : boolean ) {
220
225
var context = this . _readContext ( proto ) ;
221
226
var pipe = this . _pipeFor ( proto , context ) ;
222
227
var prevValue = this . _readSelf ( proto ) ;
223
228
224
- var newValue = pipe . transform ( context ) ;
229
+ var currValue = pipe . transform ( context ) ;
225
230
226
- if ( ! isSame ( prevValue , newValue ) ) {
227
- newValue = ChangeDetectionUtil . unwrapValue ( newValue ) ;
228
-
229
- this . _writeSelf ( proto , newValue ) ;
230
- this . _setChanged ( proto , true ) ;
231
+ if ( ! isSame ( prevValue , currValue ) ) {
232
+ currValue = ChangeDetectionUtil . unwrapValue ( currValue ) ;
231
233
232
234
if ( proto . lastInBinding ) {
233
- return ChangeDetectionUtil . simpleChange ( prevValue , newValue ) ;
235
+ var change = ChangeDetectionUtil . simpleChange ( prevValue , currValue ) ;
236
+ if ( throwOnChange ) ChangeDetectionUtil . throwOnChange ( proto , change ) ;
237
+
238
+ this . _writeSelf ( proto , currValue ) ;
239
+ this . _setChanged ( proto , true ) ;
240
+
241
+ return change ;
242
+
234
243
} else {
244
+ this . _writeSelf ( proto , currValue ) ;
245
+ this . _setChanged ( proto , true ) ;
235
246
return null ;
236
247
}
237
248
} else {
0 commit comments