From 83f1856d6ae1226923c7abd26062f23ebfdeb421 Mon Sep 17 00:00:00 2001 From: Tim Blasi Date: Tue, 2 Jun 2015 18:07:44 -0700 Subject: [PATCH] feat(dart/transform): Add support for the safe navigation operator Adds support for ?. to pregenerated Dart Change Detectors. Closes #791 --- .../template_compiler/change_detector_codegen.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/angular2/src/transform/template_compiler/change_detector_codegen.dart b/modules/angular2/src/transform/template_compiler/change_detector_codegen.dart index 2ad4a9e409..2916382e77 100644 --- a/modules/angular2/src/transform/template_compiler/change_detector_codegen.dart +++ b/modules/angular2/src/transform/template_compiler/change_detector_codegen.dart @@ -303,6 +303,10 @@ class _CodegenState { rhs = '$context.${r.name}'; break; + case RECORD_TYPE_SAFE_PROPERTY: + rhs = '${_UTIL}.isValueBlank(${context}) ? null : ${context}.${r.name}'; + break; + case RECORD_TYPE_LOCAL: rhs = '$_LOCALS_ACCESSOR.get("${r.name}")'; break; @@ -311,6 +315,11 @@ class _CodegenState { rhs = '$context.${r.name}($argString)'; break; + case RECORD_TYPE_SAFE_INVOKE_METHOD: + rhs = '${_UTIL}.isValueBlank(${context}) ' + '? null : ${context}.${r.name}(${argString})'; + break; + case RECORD_TYPE_INVOKE_CLOSURE: rhs = '$context($argString)'; break;