Determine whether or not a dictionary has any members present, or if it is empty |
||||
Issue descriptionFetch spec has the check, and we would like each dictionary to have such a predicate. Currently we list (supported) members manually but it's error prone.
,
Jul 4
,
Jul 4
JFYI, now from Blink C++ code, you can use dict.hasMember() --> returns true iff the member is present dict.member() --> returns nullptr if the member is not present or 'null' for nullable interface members.
,
Jul 6
Two things:
1.)
> dict.hasMember() --> returns true iff the member is present
Hmm, this is not my experience given a fresh rebase and build. Like before, `hasMember()` returns false for me when a given nullable interface's developer-provided value is `null`. For example, with `new Request("", {signal: null})`, `init.hasSignal()` returns false for me. This is because the generated code still sets `has_signal_ = false` in the generated `setSignalToNull()`. Will this be fixed peria@?
2.) I think yhirano@'s intention with this issue was to provide a better (more native) way to perform [1]. I've changed the title a bit. Basically we have a situation where we need to know if a dictionary was given any valid values at all, or if is completely empty. With this in mind, it might be nice to have all dictionaries supply a `areAnyMembersSet()` (returns bool). This requires all dictionaries to carry around an extra member, which will probably make the binary bigger, so I'm not sure if it will be accepted.
[1]: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/fetch/request.cc?q=fetch/request.cc&sq=package:chromium&g=0&l=82
,
Jul 11
IDL compiler was updated, and I think it works as #3. Please let me know again if something works as not intended.
,
Jul 11
yhirano@ told me that my understanding was wrong. I missed 2) in #4. My update was only for 1).
,
Jul 11
Do you have plans to address 2) in #4, or is that a WONTFIX?
,
Jul 11
Not WONTFIX, but I have no plan to address it at the moment. This is a FR, so it depends on your request priority. As you know, current hasFoo() functions do not figure their presences precisely. So I wonder whether it is good to have a function like anyMemberPresent() using hasFoo().
,
Jul 12
Makes sense. It'd be nice to have, but not a very high priority at this point, as it is unlikely that more members will be added to RequestInit in the short-term.
,
Jul 13
Feel free to raise this priority if you think this feature is needed. :) Technically it is not difficult. |
||||
►
Sign in to add a comment |
||||
Comment 1 by domfarolino@gmail.com
, Jul 4