-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
input.valueAsDate violate "obj.attribute === obj.attribute must always hold" #139
Comments
There's nothing to be done here. valueAsDate violates this principle, and was poorly designed. If we could change it, we would, but it's too late now. We should not change the design principles to accomodate bad design. Instead we should use them to prevent future instances of bad design. I think (2) is already implemented in the design principles. |
So could we make the text clear that
It will also helpful to add link to https://w3ctag.github.io/design-principles/#times-and-dates part.
I wonder if we can add a new api using Temporal to replace |
Hi, I'm half-remembering a comment @dbaron made on one of our design reviews, in which he described two levels of "badness" WRT violating this invariant: in the "less bad" cases, a developer probably wouldn't be surprised at the invariant violation. Datetimes are possibly a good example of this. In the "more bad" cases, there isn't any indication by the nature of the API that it would violate this invariant. David, do you remember where you made a comment along those lines? Do you think your reasoning applies in this case? |
I think I remember making a comment like that more than once, but only with respect to other principles in our design principles document; I don't remember one regarding this principle in particular. The ones I remember were:
|
(And I don't particularly think it applies here; I think in this case the principle suggests that this should have been a method rather than an attribute.) |
Maybe we can wrap this issue up this week and make a PR to the doc? We will discuss on the plenary call. |
I think the section should probably say "if your attribute doesn't do this, you should consider making it a method instead", and then with that we should be able to close this issue as far as the design principles doc is concerned. |
input.valueAsDate
violate this.Possible solutions:
obj.attribute === obj.attribute
, orinput.valueAsDate()
) in future design, orinput.valueAsDate
as mistake (should return a subclassed Date instance which throw when call setXXX).The text was updated successfully, but these errors were encountered: