mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[dart:html] Mark setters nullable if incompatible as well
Getter types need to be a subtype of the setter type, so if getters are nullable due to incompatibility, the setter needs to be as well. This change makes those changes, updates documentation, and modifies a template and test file. Change-Id: I2130538bb4005b3553eb7951af022c1c2ed59c1e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152607 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
parent
974be4805c
commit
e24f205d16
File diff suppressed because it is too large
Load diff
|
@ -660,7 +660,7 @@ class Index extends Interceptor {
|
|||
|
||||
String? get name native;
|
||||
|
||||
set name(String value) native;
|
||||
set name(String? value) native;
|
||||
|
||||
ObjectStore? get objectStore native;
|
||||
|
||||
|
@ -890,7 +890,7 @@ class ObjectStore extends Interceptor {
|
|||
|
||||
String? get name native;
|
||||
|
||||
set name(String value) native;
|
||||
set name(String? value) native;
|
||||
|
||||
Transaction? get transaction native;
|
||||
|
||||
|
|
|
@ -86,15 +86,15 @@ class Angle extends Interceptor {
|
|||
|
||||
num? get value native;
|
||||
|
||||
set value(num value) native;
|
||||
set value(num? value) native;
|
||||
|
||||
String? get valueAsString native;
|
||||
|
||||
set valueAsString(String value) native;
|
||||
set valueAsString(String? value) native;
|
||||
|
||||
num? get valueInSpecifiedUnits native;
|
||||
|
||||
set valueInSpecifiedUnits(num value) native;
|
||||
set valueInSpecifiedUnits(num? value) native;
|
||||
|
||||
void convertToSpecifiedUnits(int unitType) native;
|
||||
|
||||
|
@ -222,7 +222,7 @@ class AnimatedBoolean extends Interceptor {
|
|||
|
||||
bool? get baseVal native;
|
||||
|
||||
set baseVal(bool value) native;
|
||||
set baseVal(bool? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -240,7 +240,7 @@ class AnimatedEnumeration extends Interceptor {
|
|||
|
||||
int? get baseVal native;
|
||||
|
||||
set baseVal(int value) native;
|
||||
set baseVal(int? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -258,7 +258,7 @@ class AnimatedInteger extends Interceptor {
|
|||
|
||||
int? get baseVal native;
|
||||
|
||||
set baseVal(int value) native;
|
||||
set baseVal(int? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -308,7 +308,7 @@ class AnimatedNumber extends Interceptor {
|
|||
|
||||
num? get baseVal native;
|
||||
|
||||
set baseVal(num value) native;
|
||||
set baseVal(num? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -374,7 +374,7 @@ class AnimatedString extends Interceptor {
|
|||
|
||||
String? get baseVal native;
|
||||
|
||||
set baseVal(String value) native;
|
||||
set baseVal(String? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -1962,7 +1962,7 @@ class ImageElement extends GraphicsElement implements UriReference {
|
|||
|
||||
String? get async native;
|
||||
|
||||
set async(String value) native;
|
||||
set async(String? value) native;
|
||||
|
||||
AnimatedLength? get height native;
|
||||
|
||||
|
@ -2018,15 +2018,15 @@ class Length extends Interceptor {
|
|||
|
||||
num? get value native;
|
||||
|
||||
set value(num value) native;
|
||||
set value(num? value) native;
|
||||
|
||||
String? get valueAsString native;
|
||||
|
||||
set valueAsString(String value) native;
|
||||
set valueAsString(String? value) native;
|
||||
|
||||
num? get valueInSpecifiedUnits native;
|
||||
|
||||
set valueInSpecifiedUnits(num value) native;
|
||||
set valueInSpecifiedUnits(num? value) native;
|
||||
|
||||
void convertToSpecifiedUnits(int unitType) native;
|
||||
|
||||
|
@ -2279,27 +2279,27 @@ class Matrix extends Interceptor {
|
|||
|
||||
num? get a native;
|
||||
|
||||
set a(num value) native;
|
||||
set a(num? value) native;
|
||||
|
||||
num? get b native;
|
||||
|
||||
set b(num value) native;
|
||||
set b(num? value) native;
|
||||
|
||||
num? get c native;
|
||||
|
||||
set c(num value) native;
|
||||
set c(num? value) native;
|
||||
|
||||
num? get d native;
|
||||
|
||||
set d(num value) native;
|
||||
set d(num? value) native;
|
||||
|
||||
num? get e native;
|
||||
|
||||
set e(num value) native;
|
||||
set e(num? value) native;
|
||||
|
||||
num? get f native;
|
||||
|
||||
set f(num value) native;
|
||||
set f(num? value) native;
|
||||
|
||||
Matrix flipX() native;
|
||||
|
||||
|
@ -2355,7 +2355,7 @@ class Number extends Interceptor {
|
|||
|
||||
num? get value native;
|
||||
|
||||
set value(num value) native;
|
||||
set value(num? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -2522,11 +2522,11 @@ class Point extends Interceptor {
|
|||
|
||||
num? get x native;
|
||||
|
||||
set x(num value) native;
|
||||
set x(num? value) native;
|
||||
|
||||
num? get y native;
|
||||
|
||||
set y(num value) native;
|
||||
set y(num? value) native;
|
||||
|
||||
Point matrixTransform(Matrix matrix) native;
|
||||
}
|
||||
|
@ -2656,11 +2656,11 @@ class PreserveAspectRatio extends Interceptor {
|
|||
|
||||
int? get align native;
|
||||
|
||||
set align(int value) native;
|
||||
set align(int? value) native;
|
||||
|
||||
int? get meetOrSlice native;
|
||||
|
||||
set meetOrSlice(int value) native;
|
||||
set meetOrSlice(int? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -2710,19 +2710,19 @@ class Rect extends Interceptor {
|
|||
|
||||
num? get height native;
|
||||
|
||||
set height(num value) native;
|
||||
set height(num? value) native;
|
||||
|
||||
num? get width native;
|
||||
|
||||
set width(num value) native;
|
||||
set width(num? value) native;
|
||||
|
||||
num? get x native;
|
||||
|
||||
set x(num value) native;
|
||||
set x(num? value) native;
|
||||
|
||||
num? get y native;
|
||||
|
||||
set y(num value) native;
|
||||
set y(num? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -2781,7 +2781,7 @@ class ScriptElement extends SvgElement implements UriReference {
|
|||
|
||||
String? get type native;
|
||||
|
||||
set type(String value) native;
|
||||
set type(String? value) native;
|
||||
|
||||
// From SVGURIReference
|
||||
|
||||
|
@ -2939,21 +2939,21 @@ class StyleElement extends SvgElement {
|
|||
|
||||
bool? get disabled native;
|
||||
|
||||
set disabled(bool value) native;
|
||||
set disabled(bool? value) native;
|
||||
|
||||
String? get media native;
|
||||
|
||||
set media(String value) native;
|
||||
set media(String? value) native;
|
||||
|
||||
StyleSheet? get sheet native;
|
||||
|
||||
// Use implementation from Element.
|
||||
// String? get title native;
|
||||
// void set title(String value) native;
|
||||
// void set title(String? value) native;
|
||||
|
||||
String? get type native;
|
||||
|
||||
set type(String value) native;
|
||||
set type(String? value) native;
|
||||
}
|
||||
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -3294,7 +3294,7 @@ class SvgElement extends Element implements GlobalEventHandlers, NoncedElement {
|
|||
|
||||
// Use implementation from Element.
|
||||
// int? get tabIndex native;
|
||||
// void set tabIndex(int value) native;
|
||||
// void set tabIndex(int? value) native;
|
||||
|
||||
SvgElement? get viewportElement native;
|
||||
|
||||
|
@ -3460,7 +3460,7 @@ class SvgSvgElement extends GraphicsElement
|
|||
|
||||
num? get currentScale native;
|
||||
|
||||
set currentScale(num value) native;
|
||||
set currentScale(num? value) native;
|
||||
|
||||
Point? get currentTranslate native;
|
||||
|
||||
|
@ -3541,7 +3541,7 @@ class SvgSvgElement extends GraphicsElement
|
|||
|
||||
int? get zoomAndPan native;
|
||||
|
||||
set zoomAndPan(int value) native;
|
||||
set zoomAndPan(int? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -4006,7 +4006,7 @@ class ViewElement extends SvgElement implements FitToViewBox, ZoomAndPan {
|
|||
|
||||
int? get zoomAndPan native;
|
||||
|
||||
set zoomAndPan(int value) native;
|
||||
set zoomAndPan(int? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -4027,7 +4027,7 @@ abstract class ZoomAndPan extends Interceptor {
|
|||
|
||||
int? get zoomAndPan native;
|
||||
|
||||
set zoomAndPan(int value) native;
|
||||
set zoomAndPan(int? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
|
|
@ -52,21 +52,21 @@ class AnalyserNode extends AudioNode {
|
|||
|
||||
int? get fftSize native;
|
||||
|
||||
set fftSize(int value) native;
|
||||
set fftSize(int? value) native;
|
||||
|
||||
int? get frequencyBinCount native;
|
||||
|
||||
num? get maxDecibels native;
|
||||
|
||||
set maxDecibels(num value) native;
|
||||
set maxDecibels(num? value) native;
|
||||
|
||||
num? get minDecibels native;
|
||||
|
||||
set minDecibels(num value) native;
|
||||
set minDecibels(num? value) native;
|
||||
|
||||
num? get smoothingTimeConstant native;
|
||||
|
||||
set smoothingTimeConstant(num value) native;
|
||||
set smoothingTimeConstant(num? value) native;
|
||||
|
||||
void getByteFrequencyData(Uint8List array) native;
|
||||
|
||||
|
@ -146,15 +146,15 @@ class AudioBufferSourceNode extends AudioScheduledSourceNode {
|
|||
|
||||
bool? get loop native;
|
||||
|
||||
set loop(bool value) native;
|
||||
set loop(bool? value) native;
|
||||
|
||||
num? get loopEnd native;
|
||||
|
||||
set loopEnd(num value) native;
|
||||
set loopEnd(num? value) native;
|
||||
|
||||
num? get loopStart native;
|
||||
|
||||
set loopStart(num value) native;
|
||||
set loopStart(num? value) native;
|
||||
|
||||
AudioParam? get playbackRate native;
|
||||
|
||||
|
@ -309,15 +309,15 @@ class AudioNode extends EventTarget {
|
|||
|
||||
int? get channelCount native;
|
||||
|
||||
set channelCount(int value) native;
|
||||
set channelCount(int? value) native;
|
||||
|
||||
String? get channelCountMode native;
|
||||
|
||||
set channelCountMode(String value) native;
|
||||
set channelCountMode(String? value) native;
|
||||
|
||||
String? get channelInterpretation native;
|
||||
|
||||
set channelInterpretation(String value) native;
|
||||
set channelInterpretation(String? value) native;
|
||||
|
||||
BaseAudioContext? get context native;
|
||||
|
||||
|
@ -357,7 +357,7 @@ class AudioParam extends Interceptor {
|
|||
|
||||
num? get value native;
|
||||
|
||||
set value(num value) native;
|
||||
set value(num? value) native;
|
||||
|
||||
AudioParam cancelAndHoldAtTime(num startTime) native;
|
||||
|
||||
|
@ -503,7 +503,7 @@ class AudioTrack extends Interceptor {
|
|||
|
||||
bool? get enabled native;
|
||||
|
||||
set enabled(bool value) native;
|
||||
set enabled(bool? value) native;
|
||||
|
||||
String? get id native;
|
||||
|
||||
|
@ -720,7 +720,7 @@ class BiquadFilterNode extends AudioNode {
|
|||
|
||||
String? get type native;
|
||||
|
||||
set type(String value) native;
|
||||
set type(String? value) native;
|
||||
|
||||
void getFrequencyResponse(Float32List frequencyHz, Float32List magResponse,
|
||||
Float32List phaseResponse) native;
|
||||
|
@ -825,7 +825,7 @@ class ConvolverNode extends AudioNode {
|
|||
|
||||
bool? get normalize native;
|
||||
|
||||
set normalize(bool value) native;
|
||||
set normalize(bool? value) native;
|
||||
}
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
|
@ -1111,7 +1111,7 @@ class OscillatorNode extends AudioScheduledSourceNode {
|
|||
|
||||
String? get type native;
|
||||
|
||||
set type(String value) native;
|
||||
set type(String? value) native;
|
||||
|
||||
void setPeriodicWave(PeriodicWave periodicWave) native;
|
||||
}
|
||||
|
@ -1140,23 +1140,23 @@ class PannerNode extends AudioNode {
|
|||
|
||||
num? get coneInnerAngle native;
|
||||
|
||||
set coneInnerAngle(num value) native;
|
||||
set coneInnerAngle(num? value) native;
|
||||
|
||||
num? get coneOuterAngle native;
|
||||
|
||||
set coneOuterAngle(num value) native;
|
||||
set coneOuterAngle(num? value) native;
|
||||
|
||||
num? get coneOuterGain native;
|
||||
|
||||
set coneOuterGain(num value) native;
|
||||
set coneOuterGain(num? value) native;
|
||||
|
||||
String? get distanceModel native;
|
||||
|
||||
set distanceModel(String value) native;
|
||||
set distanceModel(String? value) native;
|
||||
|
||||
num? get maxDistance native;
|
||||
|
||||
set maxDistance(num value) native;
|
||||
set maxDistance(num? value) native;
|
||||
|
||||
AudioParam? get orientationX native;
|
||||
|
||||
|
@ -1166,7 +1166,7 @@ class PannerNode extends AudioNode {
|
|||
|
||||
String? get panningModel native;
|
||||
|
||||
set panningModel(String value) native;
|
||||
set panningModel(String? value) native;
|
||||
|
||||
AudioParam? get positionX native;
|
||||
|
||||
|
@ -1176,11 +1176,11 @@ class PannerNode extends AudioNode {
|
|||
|
||||
num? get refDistance native;
|
||||
|
||||
set refDistance(num value) native;
|
||||
set refDistance(num? value) native;
|
||||
|
||||
num? get rolloffFactor native;
|
||||
|
||||
set rolloffFactor(num value) native;
|
||||
set rolloffFactor(num? value) native;
|
||||
|
||||
void setOrientation(num x, num y, num z) native;
|
||||
|
||||
|
@ -1298,5 +1298,5 @@ class WaveShaperNode extends AudioNode {
|
|||
|
||||
String? get oversample native;
|
||||
|
||||
set oversample(String value) native;
|
||||
set oversample(String? value) native;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class MockHtmlDocument extends Mock
|
|||
class MockWindow extends Mock with _EventListeners implements Window {
|
||||
Stream<Event> get onBeforeUnload => new Stream.fromIterable([]);
|
||||
|
||||
String name = "MOCK_NAME";
|
||||
String? name = "MOCK_NAME";
|
||||
}
|
||||
|
||||
@proxy
|
||||
|
|
|
@ -833,23 +833,19 @@ class HtmlDartGenerator(object):
|
|||
attr_name == 'isContentEditable' and self._dart_js_interop):
|
||||
return
|
||||
else:
|
||||
template = '\n $GET_TYPE get $NAME;\n'
|
||||
template = '\n $TYPE get $NAME;\n'
|
||||
else:
|
||||
template = '\n $GET_TYPE get $NAME native;\n' \
|
||||
'\n set $NAME($SET_TYPE value) native;\n'
|
||||
template = '\n $TYPE get $NAME native;\n' \
|
||||
'\n set $NAME($TYPE value) native;\n'
|
||||
|
||||
# Getter nullability is determined by attribute compatibility.
|
||||
# Nullability is determined by attribute compatibility.
|
||||
is_compat = self._mdn_reader.is_compatible(attribute)
|
||||
get_type = self.SecureOutputType(attribute.type.id,
|
||||
nullable=(not is_compat) or
|
||||
attribute.type.nullable)
|
||||
set_type = self.SecureOutputType(attribute.type.id,
|
||||
nullable=attribute.type.nullable)
|
||||
nullable = attribute.type.nullable or not is_compat
|
||||
|
||||
self._members_emitter.Emit(template,
|
||||
NAME=attr_name,
|
||||
GET_TYPE=get_type,
|
||||
SET_TYPE=set_type)
|
||||
TYPE=self.SecureOutputType(
|
||||
attribute.type.id, nullable=nullable))
|
||||
|
||||
def DeclareOperation(self, operation, return_type_name, method_name):
|
||||
""" Declares an operation but does not include the code to invoke it.
|
||||
|
|
|
@ -1141,9 +1141,9 @@ def _GetPromiseAttributeType(interface_operation):
|
|||
return promise_attributes[interface_operation]
|
||||
return None
|
||||
|
||||
# Compatibility is used to help determine getter nullability i.e. if the
|
||||
# attribute is not compatible across all browsers, the getter is marked as
|
||||
# nullable. There are cases where the attribute belongs to a class that
|
||||
# Compatibility is used to help determine attribute nullability i.e. if the
|
||||
# attribute is not compatible across all browsers, the getter/setter is marked
|
||||
# as nullable. There are cases where the attribute belongs to a class that
|
||||
# implements an interface whose methods are not in the IDL, however.
|
||||
# Since attribute getters need to match their overridden method declaration,
|
||||
# there are conflicts when the overriding method is not compatible, the
|
||||
|
@ -1434,9 +1434,8 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
# Compatible attribute, use the superclass property. This
|
||||
# works because JavaScript will do its own dynamic dispatch.
|
||||
|
||||
# Getter nullability is determined by attribute
|
||||
# compatibility.
|
||||
get_nullable = (not is_compat) or attribute.type.nullable
|
||||
# Nullability is determined by attribute compatibility.
|
||||
nullable = not is_compat or attribute.type.nullable
|
||||
self._members_emitter.Emit(
|
||||
'\n'
|
||||
' // Use implementation from $SUPER.\n'
|
||||
|
@ -1446,10 +1445,10 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
NAME=html_name,
|
||||
GET_TYPE=self.SecureOutputType(attribute.type.id,
|
||||
can_narrow_type=read_only,
|
||||
nullable=get_nullable),
|
||||
nullable=nullable),
|
||||
SET_TYPE=self.SecureOutputType(attribute.type.id,
|
||||
can_narrow_type=read_only,
|
||||
nullable=attribute.type.nullable or \
|
||||
nullable=nullable or \
|
||||
'TreatNullAs' in attribute.ext_attrs))
|
||||
return
|
||||
self._members_emitter.Emit('\n // Shadowing definition.')
|
||||
|
@ -1546,6 +1545,20 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
self._AddAttributeUsingProperties(attribute, html_name,
|
||||
read_only, rename, metadata)
|
||||
|
||||
def _IsACompatibilityConflict(self, interface, attr):
|
||||
if interface in compat_conflicts and attr.id in compat_conflicts[
|
||||
interface]:
|
||||
is_compat = self._mdn_reader.is_compatible(attr)
|
||||
if is_compat or attr.type.nullable:
|
||||
# Only attributes that are not compatible and not nullable
|
||||
# belong in this list.
|
||||
raise ValueError(
|
||||
interface + '.' + attr.id +
|
||||
' has no conflict between compatibility and nullability.')
|
||||
else:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _AddAttributeUsingProperties(self, attribute, html_name, read_only,
|
||||
rename=None, metadata=None):
|
||||
self._AddRenamingGetter(attribute, html_name, rename, metadata)
|
||||
|
@ -1557,23 +1570,15 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
conversion = self._OutputConversion(attr.type.id, attr.id)
|
||||
if conversion:
|
||||
return self._AddConvertingGetter(attr, html_name, conversion)
|
||||
# Getter nullability is determined by attribute compatibility.
|
||||
# If the attribute is incompatible, it must be marked nullable.
|
||||
is_compat = self._mdn_reader.is_compatible(attr)
|
||||
return_type = self.SecureOutputType(attr.type.id,
|
||||
nullable=(not is_compat) or
|
||||
attr.type.nullable)
|
||||
native_type = self._NarrowToImplementationType(attr.type.id)
|
||||
interface = self._interface.id
|
||||
non_null_return_type = self.SecureOutputType(attr.type.id,
|
||||
nullable=False)
|
||||
if interface in compat_conflicts and attr.id in compat_conflicts[
|
||||
interface]:
|
||||
if is_compat or attr.type.nullable:
|
||||
# Only attributes that are not compatible and not nullable
|
||||
# belong in this list.
|
||||
raise ValueError(
|
||||
interface + '.' + attr.id +
|
||||
' has no conflict between compatibility and nullability.')
|
||||
if self._IsACompatibilityConflict(self._interface.id, attr):
|
||||
if not rename:
|
||||
rename = '@JSName(\'%s\')' % html_name
|
||||
template = """\n
|
||||
|
@ -1607,8 +1612,13 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
# converting getter. We need to make sure the setter type matches the
|
||||
# getter type.
|
||||
conversion = self._OutputConversion(attr.type.id, attr.id)
|
||||
if conversion and conversion.nullable_output:
|
||||
# If the attribute is incompatible, it must be marked nullable.
|
||||
is_compat = self._mdn_reader.is_compatible(attr)
|
||||
if (conversion and conversion.nullable_output) or not is_compat:
|
||||
nullable_type = True
|
||||
if self._IsACompatibilityConflict(self._interface.id, attr):
|
||||
# Force non-nullable if it's a manual conflict.
|
||||
nullable_type = False
|
||||
self._members_emitter.Emit(
|
||||
'\n $RENAME'
|
||||
'\n $STATIC set $HTML_NAME($TYPE value) native;'
|
||||
|
@ -1622,9 +1632,9 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
# dynamic should not be marked with ?
|
||||
nullable_out = conversion.nullable_output and \
|
||||
not conversion.output_type == 'dynamic'
|
||||
# Getter nullability is determined by attribute compatibility.
|
||||
# Nullability is determined by attribute compatibility.
|
||||
is_compat = self._mdn_reader.is_compatible(attr)
|
||||
nullable_in = ((not is_compat) or attr.type.nullable) and \
|
||||
nullable_in = (not is_compat or attr.type.nullable) and \
|
||||
not conversion.input_type == 'dynamic'
|
||||
self._members_emitter.Emit(
|
||||
'\n $(METADATA)$RETURN_TYPE$NULLABLE_OUT get $HTML_NAME => '
|
||||
|
@ -1648,9 +1658,11 @@ class Dart2JSBackend(HtmlDartGenerator):
|
|||
not conversion.nullable_input else '')
|
||||
|
||||
def _AddConvertingSetter(self, attr, html_name, conversion):
|
||||
# If the attribute is incompatible, it must be marked nullable.
|
||||
is_compat = self._mdn_reader.is_compatible(attr)
|
||||
# If the attribute is nullable, the setter should be nullable.
|
||||
nullable_in = (attr.type.nullable or 'TreatNullAs' in attr.ext_attrs) \
|
||||
and not conversion.input_type == 'dynamic'
|
||||
nullable_in = ((attr.type.nullable or 'TreatNullAs' in attr.ext_attrs) \
|
||||
and not conversion.input_type == 'dynamic') or not is_compat
|
||||
nullable_out = conversion.nullable_output and \
|
||||
not conversion.output_type == 'dynamic'
|
||||
self._members_emitter.Emit(
|
||||
|
|
|
@ -54,16 +54,16 @@ abstract class InputElementBase implements Element {
|
|||
set autofocus(bool value);
|
||||
|
||||
bool$NULLABLE get disabled;
|
||||
set disabled(bool value);
|
||||
set disabled(bool$NULLABLE value);
|
||||
|
||||
bool$NULLABLE get incremental;
|
||||
set incremental(bool value);
|
||||
set incremental(bool$NULLABLE value);
|
||||
|
||||
bool$NULLABLE get indeterminate;
|
||||
set indeterminate(bool value);
|
||||
set indeterminate(bool$NULLABLE value);
|
||||
|
||||
String$NULLABLE get name;
|
||||
set name(String value);
|
||||
set name(String$NULLABLE value);
|
||||
|
||||
String$NULLABLE get value;
|
||||
set value(String$NULLABLE value);
|
||||
|
@ -97,7 +97,7 @@ abstract class TextInputElementBase implements InputElementBase {
|
|||
set autocomplete(String value);
|
||||
|
||||
int$NULLABLE get maxLength;
|
||||
set maxLength(int value);
|
||||
set maxLength(int$NULLABLE value);
|
||||
|
||||
String get pattern;
|
||||
set pattern(String value);
|
||||
|
@ -106,13 +106,13 @@ abstract class TextInputElementBase implements InputElementBase {
|
|||
set placeholder(String value);
|
||||
|
||||
bool$NULLABLE get readOnly;
|
||||
set readOnly(bool value);
|
||||
set readOnly(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
||||
int$NULLABLE get size;
|
||||
set size(int value);
|
||||
set size(int$NULLABLE value);
|
||||
|
||||
void select();
|
||||
|
||||
|
@ -142,7 +142,7 @@ abstract class SearchInputElement implements TextInputElementBase {
|
|||
factory SearchInputElement() => new InputElement(type: 'search');
|
||||
|
||||
String$NULLABLE get dirName;
|
||||
set dirName(String value);
|
||||
set dirName(String$NULLABLE value);
|
||||
|
||||
Element$NULLABLE get list;
|
||||
|
||||
|
@ -159,7 +159,7 @@ abstract class TextInputElement implements TextInputElementBase {
|
|||
factory TextInputElement() => new InputElement(type: 'text');
|
||||
|
||||
String$NULLABLE get dirName;
|
||||
set dirName(String value);
|
||||
set dirName(String$NULLABLE value);
|
||||
|
||||
Element$NULLABLE get list;
|
||||
}
|
||||
|
@ -228,10 +228,10 @@ abstract class EmailInputElement implements TextInputElementBase {
|
|||
Element$NULLABLE get list;
|
||||
|
||||
int$NULLABLE get maxLength;
|
||||
set maxLength(int value);
|
||||
set maxLength(int$NULLABLE value);
|
||||
|
||||
bool$NULLABLE get multiple;
|
||||
set multiple(bool value);
|
||||
set multiple(bool$NULLABLE value);
|
||||
|
||||
String get pattern;
|
||||
set pattern(String value);
|
||||
|
@ -240,13 +240,13 @@ abstract class EmailInputElement implements TextInputElementBase {
|
|||
set placeholder(String value);
|
||||
|
||||
bool$NULLABLE get readOnly;
|
||||
set readOnly(bool value);
|
||||
set readOnly(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
||||
int$NULLABLE get size;
|
||||
set size(int value);
|
||||
set size(int$NULLABLE value);
|
||||
|
||||
/// Returns true if this input type is supported on the current platform.
|
||||
static bool get supported {
|
||||
|
@ -269,16 +269,16 @@ abstract class RangeInputElementBase implements InputElementBase {
|
|||
Element$NULLABLE get list;
|
||||
|
||||
String$NULLABLE get max;
|
||||
set max(String value);
|
||||
set max(String$NULLABLE value);
|
||||
|
||||
String$NULLABLE get min;
|
||||
set min(String value);
|
||||
set min(String$NULLABLE value);
|
||||
|
||||
String$NULLABLE get step;
|
||||
set step(String value);
|
||||
set step(String$NULLABLE value);
|
||||
|
||||
num$NULLABLE get valueAsNumber;
|
||||
set valueAsNumber(num value);
|
||||
set valueAsNumber(num$NULLABLE value);
|
||||
|
||||
void stepDown([int$NULLABLE n]);
|
||||
|
||||
|
@ -298,7 +298,7 @@ abstract class DateInputElement implements RangeInputElementBase {
|
|||
set valueAsDate(DateTime value);
|
||||
|
||||
bool$NULLABLE get readOnly;
|
||||
set readOnly(bool value);
|
||||
set readOnly(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -322,7 +322,7 @@ abstract class MonthInputElement implements RangeInputElementBase {
|
|||
set valueAsDate(DateTime value);
|
||||
|
||||
bool$NULLABLE get readOnly;
|
||||
set readOnly(bool value);
|
||||
set readOnly(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -346,7 +346,7 @@ abstract class WeekInputElement implements RangeInputElementBase {
|
|||
set valueAsDate(DateTime value);
|
||||
|
||||
bool$NULLABLE get readOnly;
|
||||
set readOnly(bool value);
|
||||
set readOnly(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -370,7 +370,7 @@ abstract class TimeInputElement implements RangeInputElementBase {
|
|||
set valueAsDate(DateTime value);
|
||||
|
||||
bool$NULLABLE get readOnly;
|
||||
set readOnly(bool value);
|
||||
set readOnly(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -393,7 +393,7 @@ abstract class LocalDateTimeInputElement implements RangeInputElementBase {
|
|||
new InputElement(type: 'datetime-local');
|
||||
|
||||
bool$NULLABLE get readOnly;
|
||||
set readOnly(bool value);
|
||||
set readOnly(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -417,7 +417,7 @@ abstract class NumberInputElement implements RangeInputElementBase {
|
|||
set placeholder(String value);
|
||||
|
||||
bool$NULLABLE get readOnly;
|
||||
set readOnly(bool value);
|
||||
set readOnly(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -455,7 +455,7 @@ abstract class CheckboxInputElement implements InputElementBase {
|
|||
factory CheckboxInputElement() => new InputElement(type: 'checkbox');
|
||||
|
||||
bool$NULLABLE get checked;
|
||||
set checked(bool value);
|
||||
set checked(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -477,7 +477,7 @@ abstract class RadioButtonInputElement implements InputElementBase {
|
|||
factory RadioButtonInputElement() => new InputElement(type: 'radio');
|
||||
|
||||
bool$NULLABLE get checked;
|
||||
set checked(bool value);
|
||||
set checked(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -490,10 +490,10 @@ abstract class FileUploadInputElement implements InputElementBase {
|
|||
factory FileUploadInputElement() => new InputElement(type: 'file');
|
||||
|
||||
String$NULLABLE get accept;
|
||||
set accept(String value);
|
||||
set accept(String$NULLABLE value);
|
||||
|
||||
bool$NULLABLE get multiple;
|
||||
set multiple(bool value);
|
||||
set multiple(bool$NULLABLE value);
|
||||
|
||||
bool get required;
|
||||
set required(bool value);
|
||||
|
@ -531,7 +531,7 @@ abstract class ImageButtonInputElement implements InputElementBase {
|
|||
factory ImageButtonInputElement() => new InputElement(type: 'image');
|
||||
|
||||
String$NULLABLE get alt;
|
||||
set alt(String value);
|
||||
set alt(String$NULLABLE value);
|
||||
|
||||
String get formAction;
|
||||
set formAction(String value);
|
||||
|
@ -549,13 +549,13 @@ abstract class ImageButtonInputElement implements InputElementBase {
|
|||
set formTarget(String value);
|
||||
|
||||
int$NULLABLE get height;
|
||||
set height(int value);
|
||||
set height(int$NULLABLE value);
|
||||
|
||||
String$NULLABLE get src;
|
||||
set src(String value);
|
||||
set src(String$NULLABLE value);
|
||||
|
||||
int$NULLABLE get width;
|
||||
set width(int value);
|
||||
set width(int$NULLABLE value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -287,8 +287,9 @@ $endif
|
|||
|
||||
String get returnValue => _returnValue;
|
||||
|
||||
set returnValue(String value) {
|
||||
_returnValue = value;
|
||||
set returnValue(String$NULLABLE value) {
|
||||
// Typed as nullable only to be compatible with the overriden method.
|
||||
_returnValue = value$NULLASSERT;
|
||||
// FF and IE use the value as the return value, Chrome will return this from
|
||||
// the event callback function.
|
||||
if (JS<bool>('bool', '("returnValue" in #)', wrapped)) {
|
||||
|
|
Loading…
Reference in a new issue