- From: Majid Valipour via GitHub <sysbot+gh@w3.org>
- Date: Thu, 07 May 2020 19:54:03 +0000
- To: public-css-archive@w3.org
I got confused by the spec section that you linked because it contradicts with [this note](https://heycam.github.io/webidl/#dictionary-member-optional) in WebIDL spec regarding the dictionary. ``` In the ECMAScript binding, a value of undefined for the property corresponding to a dictionary member is treated the same as omitting that property. Thus, it will cause an error if the member is required, or will trigger the default value if one is present, or will result in no entry existing in the dictionary value otherwise. ``` But I think I now have figured out the source of the confusion. The conversion process for turning an ECMAScript Object values into an IDL dictionary ([spec ref](https://heycam.github.io/webidl/#es-dictionary)) handles undefined members differently than the conversion process for a nullable type in general (which is the one [you referenced](https://heycam.github.io/webidl/#es-nullable-type)). Here is the key part of [the algorithm](https://heycam.github.io/webidl/#es-dictionary) that converts a member of the object into a member of the dictionary: ``` esMemberValue <- ?Get(esDict, key) if (esMemberValue is defined) convert it to IDL type else if esMemberValue is undefined and member is optional and has a default value use default value otherwise if member is required throw! // note that if member is optional with no default we do nothing which leaves // the IDL dict for that key empty! ``` If I am reading this correctly an explicitly (or implicitly) undefined objected member in JS does not get mapped to null (even when using a nullable type) but it either gets a the default value if one is specified in the IDL dictionary or nothing at all. This is consistent with the note in the spec too. So I think with our current definition, we get no data members which we handles correctly. wdyt? -- GitHub Notification of comment by majido Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5013#issuecomment-625463603 using your GitHub account
Received on Thursday, 7 May 2020 19:54:06 UTC