[web-nfc] Check 'typedef any NDEFRecordData' to be a JSON type? (#307)

leonhsl has just created a new issue for https://github.com/w3c/web-nfc:

== Check 'typedef any NDEFRecordData' to be a JSON type? ==
This question comes from webnfc impl in Chromium, to make clear how to impl step 1 of http://w3c.github.io/web-nfc/#mapping-json-to-ndef:

> If the type of a record's data is not a JSON type, throw a TypeError and abort these steps.

while the record's data is defined as `typedef any NDEFRecordData` in the IDL file, I tried to look for help in blink-dev and got some quite helpful answer there.

With the following snippets, you can find more details on the thread https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/t-ehjfCrIgc.

> The WebIDL spec does use the phrase "is a JSON type", but applies it to WebIDL values rather than to ECMAScript values, meaning the sort of WebIDL values that can legally be returned from toJSON. The NFC spec seems to be trying to discriminate on the type of the ECMAScript value, which isn't how this is supposed to work.

> In general specs that test “JSONness” of a value are just broken.

> We did a similar fix in Payment Request some years ago that you may find instructive. See https://github.com/w3c/payment-request/issues/307, https://github.com/w3c/payment-request/pull/382, and https://github.com/w3c/payment-request/pull/404

We may need to refine webnfc spec.

@riju @reillyon @kenchris @domenic @marcoscaceres @beaufortfrancois 

Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/307 using your GitHub account

Received on Friday, 23 August 2019 06:20:11 UTC