The signature of overridden methods for maplike/setlike should match that of default methods
Categories
(Core :: DOM: Bindings (WebIDL), defect, P3)
Tracking
()
People
(Reporter: edgar, Unassigned, NeedInfo)
Details
See https://webidl.spec.whatwg.org/#idl-maplike
Note: Read-write maplike interfaces can have operations named "clear", "delete", or "set", which will override the default implementation of those methods (defined in § 3.7.11 Maplike declarations). If such operations are defined, they must match the input and output expectations of each method, defined in their default implementation sections.
And https://webidl.spec.whatwg.org/#es-map-delete
If the interface does declare a delete method, it should similarly map a -0 key to +0, and must return a boolean indicating whether the key was present or not.
WebIDL parser should throw error if signature of overridden methods isn't matched.
Comment 1•2 years ago
|
||
Maybe noteworthy here (even though more related to bug 1799890): JS world uses methods that start with a lower key (clear()
, delete()
) while C++ methods (per convention) start with an Upper key (Clear()
, Delete()
).
This does actually make a difference when it comes to range-based iteration. Things like for(auto& iter: array) {}
only work if the class provides begin()
and end()
iteration methods which start with a lower key.
Reporter | ||
Comment 2•1 year ago
|
||
(In reply to Edgar Chen [:edgar] from comment #0)
WebIDL parser should throw error if signature of overridden methods isn't matched.
We could address this around https://searchfox.org/mozilla-central/rev/8011b6325f7ce05d228a3cdefd45d74fb98ee7b4/dom/bindings/parser/WebIDL.py#4883-4889. :jjaschke, ni? you in case you are interested.
Updated•1 year ago
|
Description
•