@@ -967,7 +967,7 @@ At a high level, the additional coercions would be:
967
967
| ` float32 ` , ` float64 ` | as a Number, mapping the canonical NaN to [ JS NaN] | ` ToNumber ` mapping [ JS NaN] to the canonical NaN |
968
968
| ` char ` | same as [ ` USVString ` ] | same as [ ` USVString ` ] , throw if the USV length is not 1 |
969
969
| ` record ` | TBD: maybe a [ JS Record] ? | same as [ ` dictionary ` ] |
970
- | ` variant ` | TBD | TBD |
970
+ | ` variant ` | see below | see below |
971
971
| ` list ` | create a typed array copy for number types; otherwise produce a JS array (like [ ` sequence ` ] ) | same as [ ` sequence ` ] |
972
972
| ` string ` | same as [ ` USVString ` ] | same as [ ` USVString ` ] |
973
973
| ` tuple ` | TBD: maybe a [ JS Tuple] ? | TBD |
@@ -985,6 +985,14 @@ Notes:
985
985
the return value is specified by ` ToJSValue ` above. Otherwise, the function
986
986
result is wrapped into a JS object whose field names are taken from the result
987
987
names and whose field values are specified by ` ToJSValue ` above.
988
+ * In lieu of an existing standard JS representation for ` variant ` , the JS API
989
+ would need to define its own custom binding built from objects. As a sketch,
990
+ the JS values accepted by ` (variant (case "a" u32) (case "b" string)) ` could
991
+ include ` { a: 42 } ` and ` { b: "hi" } ` .
992
+ * For ` union ` and ` option ` , when Web IDL doesn't support particular type
993
+ combinations (e.g., ` (option (option u32)) ` ), the JS API would fall back to
994
+ the JS API of the unspecialized ` variant ` (e.g.,
995
+ ` (variant (case "some" (variant (case "some" u32) (case "none"))) (case "none")) ` ).
988
996
* The forthcoming addition of [ resource and handle types] would additionally
989
997
allow coercion to and from the remaining Symbol and Object JavaScript value
990
998
types.
0 commit comments