feat: add support for the safe navigation (aka Elvis) operator
fixes #791
This commit is contained in:
@ -19,7 +19,9 @@ import {
|
||||
RECORD_TYPE_KEYED_ACCESS,
|
||||
RECORD_TYPE_PIPE,
|
||||
RECORD_TYPE_BINDING_PIPE,
|
||||
RECORD_TYPE_INTERPOLATE
|
||||
RECORD_TYPE_INTERPOLATE,
|
||||
RECORD_TYPE_SAFE_PROPERTY,
|
||||
RECORD_TYPE_SAFE_INVOKE_METHOD
|
||||
} from './proto_record';
|
||||
|
||||
import {ExpressionChangedAfterItHasBeenChecked, ChangeDetectionError} from './exceptions';
|
||||
@ -192,6 +194,10 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
||||
var context = this._readContext(proto);
|
||||
return proto.funcOrValue(context);
|
||||
|
||||
case RECORD_TYPE_SAFE_PROPERTY:
|
||||
var context = this._readContext(proto);
|
||||
return isBlank(context) ? null : proto.funcOrValue(context);
|
||||
|
||||
case RECORD_TYPE_LOCAL:
|
||||
return this.locals.get(proto.name);
|
||||
|
||||
@ -200,6 +206,14 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
||||
var args = this._readArgs(proto);
|
||||
return proto.funcOrValue(context, args);
|
||||
|
||||
case RECORD_TYPE_SAFE_INVOKE_METHOD:
|
||||
var context = this._readContext(proto);
|
||||
if (isBlank(context)) {
|
||||
return null;
|
||||
}
|
||||
var args = this._readArgs(proto);
|
||||
return proto.funcOrValue(context, args);
|
||||
|
||||
case RECORD_TYPE_KEYED_ACCESS:
|
||||
var arg = this._readArgs(proto)[0];
|
||||
return this._readContext(proto)[arg];
|
||||
|
Reference in New Issue
Block a user