OLD | NEW |
(Empty) | |
| 1 part of html_common; |
| 2 |
| 3 convertDartToNative_PrepareForStructuredClone(value) => |
| 4 new _StructuredCloneDartium().convertDartToNative_PrepareForStructuredClone(
value); |
| 5 |
| 6 convertNativeToDart_AcceptStructuredClone(object, {mustCopy: false}) => |
| 7 new _AcceptStructuredCloneDartium().convertNativeToDart_AcceptStructuredClon
e(object, mustCopy: mustCopy); |
| 8 |
| 9 class _StructuredCloneDartium extends _StructuredClone { |
| 10 newJsMap() => new js.JsObject(js.context["Object"]); |
| 11 putIntoMap(map, key, value) => map[key] = value; |
| 12 newJSList(length) => new js.JsArray(); |
| 13 cloneNotRequired(e) => e is js.JsObject; |
| 14 } |
| 15 |
| 16 class _AcceptStructuredCloneDartium extends _AcceptStructuredClone { |
| 17 newDartList(length) => new List(length); |
| 18 |
| 19 // JsObjects won't be identical, but will be equal only if the underlying |
| 20 // Js entities are identical. |
| 21 bool identicalInJs(a, b) => |
| 22 (a is js.JsObject) ? a == b : identical(a, b); |
| 23 |
| 24 void forEachJsField(jsObject, action) { |
| 25 var keys = js.context["Object"].callMethod("keys", [jsObject]); |
| 26 for (var key in keys) { |
| 27 action(key, jsObject[key]); |
| 28 } |
| 29 } |
| 30 } |
| 31 |
| 32 final _dateConstructor = js.context["Date"]; |
| 33 final _regexConstructor = js.context["RegExp"]; |
| 34 |
| 35 bool isJavaScriptDate(value) => value is js.JsObject && value.instanceof(_dateCo
nstructor); |
| 36 bool isJavaScriptRegExp(value) => value is js.JsObject && value.instanceof(_rege
xConstructor); |
| 37 bool isJavaScriptArray(value) => value is js.JsArray; |
| 38 |
| 39 final _object = js.context["Object"]; |
| 40 final _getPrototypeOf = _object["getPrototypeOf"]; |
| 41 _getProto(object) { |
| 42 return _getPrototypeOf.apply([object]); |
| 43 } |
| 44 final _objectProto = js.context["Object"]["prototype"]; |
| 45 |
| 46 bool isJavaScriptSimpleObject(value) { |
| 47 if (!value is js.JsObject) return false; |
| 48 var proto = _getProto(value); |
| 49 return proto == _objectProto || proto == null; |
| 50 } |
| 51 bool isImmutableJavaScriptArray(value) => |
| 52 isJavaScriptArray(value) && value["immutable$list"] != null; |
| 53 |
| 54 final _promiseConstructor = js.context['Promise']; |
| 55 bool isJavaScriptPromise(value) => value is js.JsObject && value['constructor']
== _promiseConstructor; |
| 56 |
| 57 Future convertNativePromiseToDartFuture(js.JsObject promise) { |
| 58 var completer = new Completer(); |
| 59 var newPromise = promise |
| 60 .callMethod("then", [(result) => completer.complete(result)]) |
| 61 .callMethod("catch", [(result) => completer.completeError(result)]); |
| 62 return completer.future; |
| 63 } |
OLD | NEW |