mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
[dart2wasm] Correctly handle null when jsifying maps.
Change-Id: Ibda04bf6012447dcab86079da8d4d41771e8e9bc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262102 Commit-Queue: Joshua Litt <joshualitt@google.com> Reviewed-by: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
parent
577e34df43
commit
29de68d38e
2 changed files with 16 additions and 9 deletions
|
@ -37,8 +37,7 @@ dynamic jsify(Object? object) {
|
|||
o is Float32List ||
|
||||
o is Float64List ||
|
||||
o is ByteBuffer ||
|
||||
o is ByteData ||
|
||||
o is num) {
|
||||
o is ByteData) {
|
||||
return JSValue.box(jsifyRaw(o));
|
||||
}
|
||||
|
||||
|
@ -46,9 +45,9 @@ dynamic jsify(Object? object) {
|
|||
JSValue convertedMap = newObject<JSValue>();
|
||||
convertedObjects[o] = convertedMap;
|
||||
for (final key in o.keys) {
|
||||
JSValue convertedKey = convert(key) as JSValue;
|
||||
setPropertyRaw(convertedMap.toExternRef(), convertedKey.toExternRef(),
|
||||
(convert(o[key]) as JSValue).toExternRef());
|
||||
JSValue? convertedKey = convert(key) as JSValue?;
|
||||
setPropertyRaw(convertedMap.toExternRef(), convertedKey?.toExternRef(),
|
||||
(convert(o[key]) as JSValue?)?.toExternRef());
|
||||
}
|
||||
return convertedMap;
|
||||
} else if (o is Iterable) {
|
||||
|
|
|
@ -140,9 +140,11 @@ void deepConversionsTest() {
|
|||
['a', 'b', 'c'], dartify(jsify(['a', 'b', 'c'])) as List<Object?>);
|
||||
_expectRecEquals(
|
||||
{
|
||||
'null': 'foo',
|
||||
'foo': null,
|
||||
'a': 1,
|
||||
'b': true,
|
||||
'c': [1, 2, 3],
|
||||
'c': [1, 2, 3, null],
|
||||
'd': 'foo',
|
||||
'e': {
|
||||
'f': 2,
|
||||
|
@ -150,9 +152,11 @@ void deepConversionsTest() {
|
|||
},
|
||||
},
|
||||
dartify(jsify({
|
||||
'null': 'foo',
|
||||
'foo': null,
|
||||
'a': 1,
|
||||
'b': true,
|
||||
'c': [1, 2, 3],
|
||||
'c': [1, 2, 3, null],
|
||||
'd': 'foo',
|
||||
'e': {
|
||||
'f': 2,
|
||||
|
@ -194,9 +198,11 @@ void deepConversionsTest() {
|
|||
globalThis.e = true;
|
||||
globalThis.f = function () { return 'hello world'; };
|
||||
globalThis.g = {
|
||||
null: 'foo',
|
||||
'foo': null,
|
||||
'a': 1,
|
||||
'b': true,
|
||||
'c': [1, 2, 3],
|
||||
'c': [1, 2, 3, null],
|
||||
'd': 'foo',
|
||||
'e': {'f': 2, 'g': [2, 4, 6]},
|
||||
};
|
||||
|
@ -229,9 +235,11 @@ void deepConversionsTest() {
|
|||
Expect.equals(2.5, getProperty(gt, 'd'));
|
||||
Expect.equals(true, getProperty(gt, 'e'));
|
||||
_expectRecEquals({
|
||||
'null': 'foo',
|
||||
'foo': null,
|
||||
'a': 1,
|
||||
'b': true,
|
||||
'c': [1, 2, 3],
|
||||
'c': [1, 2, 3, null],
|
||||
'd': 'foo',
|
||||
'e': {
|
||||
'f': 2,
|
||||
|
|
Loading…
Reference in a new issue