Conversation
With the exception of the removal of "datetime" <input> type state, these changes do not appear to be observable (or testable).
Even though this is unobservable, when we refer to the <input>'s value we should always use input._value, to avoid calling the complex value getter.
Restore to the original HTML definition of nonexistent for anything other than type=week.
Also make sure to use ASCII lowercase instead of Unicode lowercase during comparison.
This is more consistent with the rest of jsdom. Also make sure there is no Unicode whitespace before the number appears.
This also provides a high-precision version of the function that returns a Decimal object, using decimal.js, should it be needed in the future.
|
My main hesitation here is that I do hope to one day add That said, this would definitely be a step in the right direction. I like the
I'm a little unsure about expressing enumerated attributes with just a set of valid values. The full complexity of the keyword-vs.-state mapping seems hard to deal with without encoding the table, which may include keywordless states, or multiple keywords per state. Good test cases here are BTW, here's a sketch of what would be needed for IDL attributes, setting aside enumerated attributes for now:
|
|
The interesting thing about the
What do you think about generalizing the webidl2js processor that we were planning to use for |
|
In general, it sounds like extended attributes would work. Let me prototype it out. This PR was created because it seemed like the most frictionless way to get more complicated reflection working at all.
This is not true. The other suggestions sound like they would work.
The more tricky attributes only seem to affect how they are interpreted semantically, not how the reflection works. So it's still okay for the IDL level to be less aware of what states the keywords will get mapped to. I think a good way to specify enumerated attributes at the IDL level could be to reuse the enum infrastructure, and have a
I'm a bit concerned about essentially hardcoding all of these names into webidl2js. Maybe a better way would be to have a "super" extended attribute that tells webidl2js to hand over the control of the attribute to a custom processor, which can then inspect the IDL in depth to figure out what to do. So instead of By the way, I don't believe |
This is a good point. I was kind of envisioning something that generated the state-mapping code for us (so that impl code could look up something like
I agree (assuming we don't need the extra state mapping information).
I think it'd be very reasonable to just hand over anything prefixed with
My understanding per whatwg/webidl#574 is that is grammatically allowed, so I think if webidl2.js tries to disallow it, we should be able to push back on them. It makes sense as a warning (similar to other "semantic" mismatches such as non-readonly promise attributes, etc.) but a parser like webidl2.js should let us do what we want here. |
|
Looks like we'd rather go forward with #2813. Closing this one then. |
This PR aims to address the longstanding issues with reflection. Currently, we support reflecting content attributes in IDL attributes using the Chrome-style [Reflect] extended attribute in webidl2js. However, this proved to be inflexible, as supporting additional reflection varieties requires putting more jsdom-specific details in webidl2js. This has resulted in better reflection support being stalled over the past few years.
This PR introduces a different way to implement reflection. Rather than putting annotations in the IDL definition, the reflection is implemented using "decorator" functions for implementation classes, much like how event listener IDL attributes are implemented currently. For example, the reflected IDL attributes of
HTMLInputElementare done as:Right now, I only introduced these very specific reflectors, though we could certainly extend it to the cases currently covered by [Reflect] in the future.
Even though brevity is on the side of [Reflect], I see several advantages for implementing reflections in the implementation file:
On the other hand, a downside for moving reflection to the implementation file is that the implementation class is not aware of the type of the IDL attribute. This makes reflection of some IDL attributes that use default behaviors that are currently serviced by [Reflect] more verbose than before. (Chrome uses a hybrid behavior, using [Reflect] for some attributes but C++ for more complex behavior.)
Admittedly, the function names are a bit long at the moment, as I'm pretty much using the spec terminology verbatim. I'm open to suggestions on better names. Another idea is we could introduce a utility function, like
addReflectedAttributes()which we can use as follows:where
kindisThis PR is rebased on top of #2786 and also uses one commit from #2789. Opening it as a draft for discussion and the Travis CI run.