-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Update all the Web IDL #2053
Update all the Web IDL #2053
Conversation
03f0002
to
75da2e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magnificent work! 👍
As a way for me to keep track of the code that'll need to be changed, as well as make it easier to write the changelog later - here is a list of the changes resulting from this which might cause any noticeable difference for jsdom users: Document
GlobalEventHandlers
HTMLBaseElement
HTMLCanvasElement
HTMLElement
HTMLEmbedElement
HTMLFormElement
HTMLFrameElement
HTMLIFrameElement
HTMLImageElement
HTMLInputElement
HTMLMediaElement
HTMLMenuElement
HTMLModElement
HTMLObjectElement
HTMLQuoteElement
HTMLSourceElement
HTMLTrackElement
HTMLVideoElement
Node
WindowEventHandlers
|
🎉 🎉 BRAVO @Zirro @TimothyGu. This is 🦄 ✨ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments about things that got added that we don't actually support, but excited about the majority of changes.
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); | ||
HTMLCollection getElementsByClassName(DOMString classNames); | ||
|
||
[NewObject] Element createElement(DOMString localName); | ||
[NewObject] Element createElementNS(DOMString? namespace, DOMString qualifiedName); | ||
[CEReactions, NewObject] Element createElement(DOMString localName, optional ElementCreationOptions options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we should add this until we actually support custom elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// https://html.spec.whatwg.org/#document | ||
enum DocumentReadyState { "loading", "interactive", "complete" }; | ||
typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work given that we don't implement SVGScriptElement?
attribute long tabIndex; | ||
void focus(); | ||
[CEReactions] attribute long tabIndex; | ||
void focus(optional FocusOptions options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should add this given that we don't implement it.
[OverrideBuiltins] | ||
[Exposed=Window, | ||
OverrideBuiltins, | ||
LegacyUnenumerableNamedProperties, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we haven't added the named/indexed properties for the form element, I'm not sure we should add these.
Thanks for the review! I'm still in the process of going over the updated IDL to determine what needs to change on the code side, what can be implemented quickly and what needs to be reverted. Indeed, for the four lines you highlighted I think I'll end up placing them behind a comment and adding a new line with the old IDL. I've already completed updates for the rest of the IDL files outside the nodes/ directory, but I think I might save them for a new pull request as this is large enough of a project already. Before this is merged, I'll need to add a USVString reflector to webidl2js. I'm using this in a local branch now: module.exports.USVString = {
get(objName, attrName) {
return `
const value = conversions["USVString"](this.getAttribute("${attrName}"));
return value === null ? "" : value;
`;
},
set(objName, attrName) {
return `this.setAttribute("${attrName}", V);`;
}
}; ...but that doesn't cover the URL reflection portion of the spec, which will probably require a new extended attribute. Implementing that might not happen until the next weekend though as I'll be pretty busy. |
Awesome! Let me assign this to you for now so I remember whose plate it is on. |
@@ -205,6 +206,12 @@ class HTMLInputElementImpl extends HTMLElementImpl { | |||
} | |||
return this[filesSymbol]; | |||
} | |||
set files(value) { | |||
if (this.type === "file" && value !== null) { | |||
this[filesSymbol] = value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch here @Zirro ! Actually ran into this myself earlier this year. Could explain failing test. Or perhaps EBKAC error. ;-)
// [CEReactions, Unscopable] void before((Node or DOMString)... nodes); | ||
// [CEReactions, Unscopable] void after((Node or DOMString)... nodes); | ||
// [CEReactions, Unscopable] void replaceWith((Node or DOMString)... nodes); | ||
[CEReactions, Unscopable] void remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My favorite diff @Zirro. Been attempting to wrangle up a list of CEReactions
myself. This will help with the custom element iteration for jsdom. Still a long way to go tho but there is progress in one of the branches.
917a9a0
to
deb266f
Compare
This is ready for a full review now 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall great work! Added some thoughts. I am currently updating MDN documentation and this helped. Also cleared up a couple impl conventions I was trying to wrap my head around.
[CEReactions, Unscopable] void before((Node or DOMString)... nodes); | ||
[CEReactions, Unscopable] void after((Node or DOMString)... nodes); | ||
[CEReactions, Unscopable] void replaceWith((Node or DOMString)... nodes); | ||
[CEReactions, Unscopable] void remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
readonly attribute DOMString origin; | ||
readonly attribute USVString URL; | ||
readonly attribute USVString documentURI; | ||
readonly attribute USVString origin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must not have gotten that memo (aka never knew) about USVString
"replacing" DOMString
. Where can I catch up on this conversion @Zirro? Thanks in advance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good place to start: whatwg/html#1282
@@ -13,20 +13,23 @@ interface Document : Node { | |||
|
|||
readonly attribute DocumentType? doctype; | |||
readonly attribute Element? documentElement; | |||
HTMLCollection getElementsByTagName(DOMString localName); | |||
HTMLCollection getElementsByTagName(DOMString qualifiedName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch on the qualifiedName
. Allowed me to read up a bit in the spec on the algorithm. Am interested because traditionally this is fast(er) internally.
The irony I just realized is methinks the API should have been .getElementsByQualifiedName
or .getElementsByLocalName
. IIRC The .tagName
of an element is an uppercased version of the qualified name.
document.getElementsByTagName('SECTION')[0].tagName // SECTION
// We are actually getting by qualifiedName
// document.getElementsByQualifiedName('section')[0].tagName // SECTION
Taken from Step 2.a
in the getElementsByTagName
algorithm
- Otherwise, if root’s node document is an HTML document, return a HTMLCollection rooted at root, whose filter matches the following descendant elements:
Whose namespace is the HTML namespace and whose qualified name is qualifiedName, in ASCII lowercase.
Which is the reason why .getElementsByTagName('SECTION')
would return a collection of <section>
s but not <SECTION>
.
Although the algo is correct. Seems user land has developed an antipattern.
// Common convention is getting by qualified name
document
.getElementsByTagName
('section')[0] // <section>...</section>
.tagName // SECTION
@TimothyGu am I mistaken in this API misnomer? Am a little rusty on HTML namespace exclusion which removes forced casing.
Just some thoughts not suggestions as they would go over to the dom spec.
// [CEReactions, NewObject] Element createElement(DOMString localName, optional ElementCreationOptions options); | ||
// [CEReactions, NewObject] Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional ElementCreationOptions options); | ||
[CEReactions, NewObject] Element createElement(DOMString localName); | ||
[CEReactions, NewObject] Element createElementNS(DOMString? namespace, DOMString qualifiedName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious. Why does .createElementNS
use qualifiedName
however .createElement
uses localName
? The Namespaces validate and extract algorithm are a little vague after reading thrice. I clicked on Name
link and brought me to a W3C
page. @domenic is this correct navigation outside the spec?
@@ -113,7 +127,7 @@ partial interface Document { | |||
[SameObject] readonly attribute StyleSheetList styleSheets; | |||
}; | |||
|
|||
// http://w3c.github.io/page-visibility/ | |||
// https://w3c.github.io/page-visibility/#extensions-to-the-document-interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
// void close(optional DOMString returnValue); | ||
// [CEReactions] void show(); | ||
// [CEReactions] void showModal(); | ||
// [CEReactions] void close(optional DOMString returnValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great comment refactor 🏆 @Zirro
|
||
[SameObject] readonly attribute HTMLFormControlsCollection elements; | ||
readonly attribute long length; | ||
readonly attribute unsigned long length; | ||
// getter Element (unsigned long index); | ||
// getter (RadioNodeList or Element) (DOMString name); | ||
|
||
void submit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why .submit
has no [CEReaction]
?
void deleteCaption(); | ||
attribute HTMLTableSectionElement? tHead; | ||
[CEReactions] void deleteCaption(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@domenic do we need extra spacing here? I know you've mentioned this to me before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the way it looks in the spec. We would prefer to make as few changes to the original formatting as possible to make updates like this one easier in the future.
interface WindowEventHandlers { | ||
attribute EventHandler onafterprint; | ||
attribute EventHandler onbeforeprint; | ||
attribute OnBeforeUnloadEventHandler onbeforeunload; | ||
attribute EventHandler onhashchange; | ||
attribute EventHandler onlanguagechange; | ||
attribute EventHandler onmessage; | ||
attribute EventHandler onmessageerror; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
test/web-platform-tests/to-run.yaml
Outdated
@@ -521,7 +521,6 @@ date.html: [fail, Unknown] | |||
datetime-local.html: [fail, Unknown] | |||
datetime.html: [fail, Unknown] | |||
email.html: [fail, Unknown] | |||
files.html: [fail, Unknown] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to-run.yaml
lists all tests that are known to be failing. When I added the setter for HTMLInputElement.files
this test began to pass and it could be removed from the list.
Thanks for the review @snuggs. I've answered your questions where I'm able to, but several of them are more related to the specification than this pull request in particular, so it might be more appropriate if you try to locate this information on your own or ask the people who write the spec instead. |
jsdom/webidl2js#95 will need to be merged ahead of this since |
Copy that @Zirro. Also 🎉 @TimothyGu for the quick merge of jsdom/webidl2js#95 |
3333d12
to
67806cc
Compare
I've rebased and incorporated the webidl2js update, but I don't understand ea733c6#diff-9f9ee474930d621ac4fe8685e273b452R2 . From what I understand we do support LegacyUnenumerableNamedProperties and OverrideBuiltins. @Zirro, do you know why you commented those out? |
@domenic I thought that's what you were saying here: #2053 (comment) - Is that not the case? |
Ah, right, sorry about that; my bad for not reviewing the whole file, but instead just the snippet I saw there. Indeed, we should only enable those when we've uncommented and implemented the getter lines. |
67806cc
to
ba3acc3
Compare
probablySupportsContext() and a setContext() stub
Uses USVString conversion or reflectURLAttribute() depending on whether the attribute is specified as containing a URL.
The longDesc attribute is defined as containing a URL, and thus uses reflectURLAttribute() which produces the whole path.
ba3acc3
to
5e875e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased. I noticed a couple things that are not showstoppers. Will probably end up merging anyway if CI comes through.
dictionary ScrollIntoViewOptions : ScrollOptions { | ||
ScrollLogicalPosition block = "start"; | ||
ScrollLogicalPosition inline = "nearest"; | ||
}; | ||
|
||
partial interface Element { | ||
[NewObject] sequence<DOMRect> getClientRects(); | ||
DOMRectList getClientRects(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems bad because we don't implement DOMRectList.
}; | ||
|
||
dictionary ShadowRootInit { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be commented out until we actually use it somewhere.
With a combination of automated and manual work, I have gone through and updated all the Web IDL files in the
nodes/
directory. The initial commit only includes the changed IDL, but there are a number of changes to the code that will need to be made before this is merged. I'll be looking closer at making those soon, as well as updating the remaining IDL in other directories.In the meantime I would appreciate help in reviewing the updated IDL.