Closed Bug 1129239 Opened 11 years ago Closed 11 years ago

Dictionaries with required properties shouldn't need to be optional

Categories

(Core :: DOM: Core & HTML, defect)

36 Branch
x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: smaug, Assigned: bzbarsky)

Details

Attachments

(2 files, 1 obsolete file)

Currently we seem to require the last param to be optional if it is a dictionary, but that doesn't quite make sense if the dictionary has required properties.
Assumin the spec changes, this would do the trick
Attachment #8558885 - Flags: review?(bugs)
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Comment on attachment 8558885 [details] [diff] [review] Don't require 'optional' keyword on trailing dictionary arguments if the dictionary has a required member Ok, so optional dictionaries with required params is still possible, but not needed. Should we handle optional dictionaries with required properties somehow differently?
Attachment #8558885 - Flags: review?(bugs) → review+
The only principled thing to do there would be to have a distinction between "not passed" and "passed" for dictionaries with required props. But in what situation would an API actually have different behavior there? That is, if you want to allow "not passed", why do you have required props? What do you do in the "not passed" case for those props?
hmm, right. Maybe there isn't good use case for that after all.
Allowed the optional to be dropped when the dictionary has required members: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27953
Oh, nice catch about ancestors with required members. I'll fix the patch here accordingly before landing it.
This required me to move a bunch of validation to validate() methods, because otherwise it was happening before the dictionary knew what its parent is. I considered having complete() on the wrapper type finish() the dictionary, but conceptually putting validation in validate() makes more sense.
Attachment #8558885 - Attachment is obsolete: true
This mostly moves stuff over to validate() and makes the union code not try to compute things needed for validation in complete(), deferring them to whenever they're asked for instead.
Attachment #8593780 - Flags: review?(bugs)
Comment on attachment 8593779 [details] [diff] [review] With the ancestor dictionary thing >+ def isOptional(self): So rename this to canBeEmpty(self) or some such ne >+ def hasOptionalDictionaryType(self): >+ return (self._dictionaryType is not None and >+ self._dictionaryType.inner.isOptional()) this too
Attachment #8593779 - Flags: review+
Attachment #8593780 - Flags: review?(bugs)
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: