From a42c072017c1702c98bf4fcf4226ab4ee357d6f7 Mon Sep 17 00:00:00 2001 From: Srujan Gaddam Date: Thu, 20 Feb 2020 20:49:26 +0000 Subject: [PATCH] Remove unnecessary null check in getPropertyValue CSSStyleDeclaration.getPropertyValue returns a non-nullable string. It will also return an empty string if the property is not found. Since getPropertyValue returns the value of the native getPropertyValue, the null check should be removed. Change-Id: I9846553d3f9fcd68cbd15b9c39d2104cab594b7a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136413 Reviewed-by: Sigmund Cherem Commit-Queue: Srujan Gaddam --- pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt | 1 - pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt | 1 - sdk/lib/html/dart2js/html_dart2js.dart | 3 +-- sdk_nnbd/lib/html/dart2js/html_dart2js.dart | 3 +-- tools/dom/scripts/css_code_generator.py | 3 +-- .../templates/html/impl/impl_CSSStyleDeclaration.darttemplate | 3 +-- 6 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt b/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt index c20ae4132b8..7bde8a216cf 100644 --- a/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt +++ b/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt @@ -15,5 +15,4 @@ WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|1476|39|5|The left WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|8384|60|5|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|9311|54|5|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/developer/developer.dart|315|25|23|The left operand can't be null, so the right operand is never executed. -WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/html/dart2js/html_dart2js.dart|4076|25|2|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/io/io.dart|9167|16|1|The left operand can't be null, so the right operand is never executed. diff --git a/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt b/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt index ccf9e8ec1f9..3bce22d9020 100644 --- a/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt +++ b/pkg/dev_compiler/tool/dartdevc_nnbd_sdk_error_golden.txt @@ -20,5 +20,4 @@ WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|8384|60|5|The left WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/_http/http.dart|9311|54|5|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/collection/collection.dart|1076|46|13|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/developer/developer.dart|332|25|23|The left operand can't be null, so the right operand is never executed. -WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/html/dart2js/html_dart2js.dart|4076|25|2|The left operand can't be null, so the right operand is never executed. WARNING|STATIC_WARNING|DEAD_NULL_COALESCE|lib/io/io.dart|9167|16|1|The left operand can't be null, so the right operand is never executed. diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart index e07517dae1a..da0e03f1c25 100644 --- a/sdk/lib/html/dart2js/html_dart2js.dart +++ b/sdk/lib/html/dart2js/html_dart2js.dart @@ -3685,8 +3685,7 @@ class CssStyleDeclaration extends Interceptor with CssStyleDeclarationBase { /// /// Please note the property name uses camelCase, not-hyphens. String getPropertyValue(String propertyName) { - var propValue = _getPropertyValueHelper(propertyName); - return propValue ?? ''; + return _getPropertyValueHelper(propertyName); } String _getPropertyValueHelper(String propertyName) { diff --git a/sdk_nnbd/lib/html/dart2js/html_dart2js.dart b/sdk_nnbd/lib/html/dart2js/html_dart2js.dart index a69ece661e5..5ace01aa3a6 100644 --- a/sdk_nnbd/lib/html/dart2js/html_dart2js.dart +++ b/sdk_nnbd/lib/html/dart2js/html_dart2js.dart @@ -4072,8 +4072,7 @@ class CssStyleDeclaration extends Interceptor with CssStyleDeclarationBase { /// /// Please note the property name uses camelCase, not-hyphens. String getPropertyValue(String propertyName) { - var propValue = _getPropertyValueHelper(propertyName); - return propValue ?? ''; + return _getPropertyValueHelper(propertyName); } String _getPropertyValueHelper(String propertyName) { diff --git a/tools/dom/scripts/css_code_generator.py b/tools/dom/scripts/css_code_generator.py index 9e71e694c25..8910ed1e919 100644 --- a/tools/dom/scripts/css_code_generator.py +++ b/tools/dom/scripts/css_code_generator.py @@ -125,8 +125,7 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME $EXTENDS with /// /// Please note the property name uses camelCase, not-hyphens. String getPropertyValue(String propertyName) { - var propValue = _getPropertyValueHelper(propertyName); - return propValue ?? ''; + return _getPropertyValueHelper(propertyName); } String _getPropertyValueHelper(String propertyName) { diff --git a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate index 6edac30e7f2..5359faa58a1 100644 --- a/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate +++ b/tools/dom/templates/html/impl/impl_CSSStyleDeclaration.darttemplate @@ -27,8 +27,7 @@ $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME $EXTENDS with /// /// Please note the property name uses camelCase, not-hyphens. String getPropertyValue(String propertyName) { - var propValue = _getPropertyValueHelper(propertyName); - return propValue ?? ''; + return _getPropertyValueHelper(propertyName); } String _getPropertyValueHelper(String propertyName) {