-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Currently, createJSInteropWrapper takes in a Dart object only (and its type as a type parameter) and wraps it with a JS object that is created with Object.create(). This is okay and at parity with createDartExport from js_util, but doesn't have the useful property of setting the prototype. We had this with createStaticInteropMock from js_util and it's useful for mocking JS values, especially when type checks are involved.
We could naturally set the prototype after the creation, but that'll deoptimize code (see the warning in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf).
Instead, we should add a parameter to pass in a prototype object to createJSInteropWrapper and use it in the underlying Object.create call.
This is also needed to remove dart:js_util from dart2wasm as well as we currently are using createStaticInteropMock to set the prototype of the object returned from List.toJSProxyOrRef. If the js_util API goes, we lost the ability to set the prototype. cc @fishythefish See #61550 for more details on that.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status