@@ -177,14 +177,39 @@ export class Record {
177177 return ! this . disabled ;
178178 }
179179
180- set disabled ( value :boolean ) {
180+ _setDisabled ( value :boolean ) {
181181 if ( value ) {
182182 this . _mode |= RECORD_FLAG_DISABLED ;
183183 } else {
184184 this . _mode &= ~ RECORD_FLAG_DISABLED ;
185185 }
186186 }
187187
188+ enable ( ) {
189+ if ( this . isEnabled ( ) ) return ;
190+
191+ var prevEnabled = this . findPrevEnabled ( ) ;
192+ var nextEnabled = this . findNextEnabled ( ) ;
193+
194+ this . prevEnabled = prevEnabled ;
195+ this . nextEnabled = nextEnabled ;
196+
197+ if ( isPresent ( prevEnabled ) ) prevEnabled . nextEnabled = this ;
198+ if ( isPresent ( nextEnabled ) ) nextEnabled . prevEnabled = this ;
199+
200+ this . _setDisabled ( false ) ;
201+ }
202+
203+ disable ( ) {
204+ var prevEnabled = this . prevEnabled ;
205+ var nextEnabled = this . nextEnabled ;
206+
207+ if ( isPresent ( prevEnabled ) ) prevEnabled . nextEnabled = nextEnabled ;
208+ if ( isPresent ( nextEnabled ) ) nextEnabled . prevEnabled = prevEnabled ;
209+
210+ this . _setDisabled ( true ) ;
211+ }
212+
188213 get isImplicitReceiver ( ) :boolean {
189214 return ( this . _mode & RECORD_FLAG_IMPLICIT_RECEIVER ) === RECORD_FLAG_IMPLICIT_RECEIVER ;
190215 }
@@ -237,7 +262,7 @@ export class Record {
237262
238263 case RECORD_TYPE_NULL :
239264 // no need to check the content again unless the context changes
240- this . recordRange . disableRecord ( this ) ;
265+ this . disable ( ) ;
241266 this . currentValue = null ;
242267 return true ;
243268
@@ -259,11 +284,11 @@ export class Record {
259284
260285 case RECORD_TYPE_INVOKE_PURE_FUNCTION :
261286 case RECORD_TYPE_INVOKE_FORMATTER :
262- this . recordRange . disableRecord ( this ) ;
287+ this . disable ( ) ;
263288 return FunctionWrapper . apply ( this . funcOrValue , this . args ) ;
264289
265290 case RECORD_TYPE_CONST :
266- this . recordRange . disableRecord ( this ) ;
291+ this . disable ( ) ;
267292 return this . funcOrValue ;
268293
269294 default :
@@ -273,12 +298,12 @@ export class Record {
273298
274299 updateArg ( value , position :int ) {
275300 this . args [ position ] = value ;
276- this . recordRange . enableRecord ( this ) ;
301+ this . enable ( ) ;
277302 }
278303
279304 updateContext ( value ) {
280305 this . context = value ;
281- this . recordRange . enableRecord ( this ) ;
306+ this . enable ( ) ;
282307
283308 if ( this . isCollection ) {
284309 if ( ArrayChanges . supports ( value ) ) {
@@ -327,7 +352,7 @@ export class Record {
327352 *
328353 * [H ER1 T] [H ER2 T] _nextEnable(ER1) will return ER2
329354 *
330- * The function skips disabled sub ranges.
355+ * The function skips disabled ranges.
331356 */
332357 findNextEnabled ( ) {
333358 if ( this . isEnabled ( ) ) return this . nextEnabled ;
@@ -348,7 +373,7 @@ export class Record {
348373 *
349374 * [H ER1 T] [H ER2 T] _nextEnable(ER2) will return ER1
350375 *
351- * The function skips disabled sub ranges.
376+ * The function skips disabled ranges.
352377 */
353378 findPrevEnabled ( ) {
354379 if ( this . isEnabled ( ) ) return this . prevEnabled ;
0 commit comments