Allow null assignments if there is a corresponding marker.
R=podivlov@chromium.org
BUG=10025
Review URL: https://codereview.chromium.org//14190019
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22067 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/tests/html/input_element_test.dart b/tests/html/input_element_test.dart
index fe90511..43f245c 100644
--- a/tests/html/input_element_test.dart
+++ b/tests/html/input_element_test.dart
@@ -177,4 +177,12 @@
check(new ButtonInputElement(), 'button');
});
});
+
+ group('attributes', () {
+ test('valueSetNull', () {
+ final e = new TextInputElement();
+ e.value = null;
+ expect(e.value, '');
+ });
+ });
}
diff --git a/tools/dom/scripts/systemnative.py b/tools/dom/scripts/systemnative.py
index 60ab062..fc27037 100644
--- a/tools/dom/scripts/systemnative.py
+++ b/tools/dom/scripts/systemnative.py
@@ -732,10 +732,22 @@
argument_expression_template, type, cls, function = \
type_info.to_native_info(argument, self._interface.id)
- if (isinstance(argument, IDLArgument) and (
- (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or
- (argument.ext_attrs.get('Default') == 'NullString') or
- _IsOptionalStringArgumentInInitEventMethod(self._interface, node, argument))):
+ def AllowsNull():
+ assert argument.ext_attrs.get('TreatNullAs', 'NullString') == 'NullString'
+ if argument.ext_attrs.get('TreatNullAs') == 'NullString':
+ return True
+
+ if isinstance(argument, IDLArgument):
+ if IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument):
+ return True
+ if argument.ext_attrs.get('Default') == 'NullString':
+ return True
+ if _IsOptionalStringArgumentInInitEventMethod(self._interface, node, argument):
+ return True
+
+ return False
+
+ if AllowsNull():
function += 'WithNullCheck'
argument_name = DartDomNameOfAttribute(argument)