Skip to content
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

Dialog Element Implementation #3403

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Dialog Element Implementation #3403

wants to merge 1 commit into from

Conversation

Hoekz
Copy link

@Hoekz Hoekz commented Jul 22, 2022

This implements the Dialog Element according to the spec: https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element

There's a couple side effects of properly getting the web platform tests to pass:

  • implemented a subset of the autofocus attribute functionality.
  • Computed styles was also only partially implemented in order to get the inert-does-not-match-disabled-selector.html test to pass.
  • The partial implementation of computed styles caused a few of the pseudo-classes tests to pass.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very exciting work! However the focusing stuff seems really mismatched from the spec. I'm hoping we can make it closer, to avoid problems in the future.

lib/jsdom/living/helpers/colors.js Outdated Show resolved Hide resolved
lib/jsdom/living/helpers/colors.js Outdated Show resolved Hide resolved
lib/jsdom/living/helpers/focusing.js Outdated Show resolved Hide resolved
lib/jsdom/living/helpers/style-rules.js Outdated Show resolved Hide resolved
return exports.outsideUnopenedDialog(child.parentNode);
};

exports.runAutoFocus = target => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. The way this is done is very unlike the spec at https://html.spec.whatwg.org/#flush-autofocus-candidates , including when you call it. Do you think it'd be feasible to implement the spec here? I'm worried that this kind of implementation will cause people to raise more bugs about autofocus not working as it does in browsers, instead of our current status of it just not being implemented...

return;
}

if (runAutoFocus(this)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runAutoFocus doesn't look like a good implementation of https://html.spec.whatwg.org/#autofocus-delegate

lib/jsdom/living/nodes/HTMLDialogElement-impl.js Outdated Show resolved Hide resolved
lib/jsdom/living/nodes/HTMLDialogElement-impl.js Outdated Show resolved Hide resolved
lib/jsdom/living/nodes/Node-impl.js Outdated Show resolved Hide resolved
lib/jsdom/living/nodes/HTMLDialogElement-impl.js Outdated Show resolved Hide resolved
@Hoekz
Copy link
Author

Hoekz commented Aug 1, 2022

Appreciate all the feedback on this! I've been looking at the focus algorithms you suggested implementing correctly (thank you for finding them, digging through the spec is a skill on its own apparently) and I think its doable, there's just a decent amount of requirements that get pulled in and life has gotten in the way of me working on it. I'm hoping to get some time to focus on it this week or at least find someone else who has some time to invest and help out.

@Hoekz
Copy link
Author

Hoekz commented Aug 22, 2022

I think I've combed through all the autofocus tests and found which ones were passable and which ones were not, but probably best to double check that...I cannot get the Script blocking style sheet implementation to work correctly and I'm not sure it can due to how some of the timing works right now, so it's been left to fail for now but is partially implemented.

@Avi-Cohen-Nehemia
Copy link

Thank you so much for all the work done in this so far!
Would love to see this getting over the line in the near future! 🙏🏼

};

function colorKeywordToRGB(name) {
if (name.toLowerCase() in RGB_LOOKUP) {
if (Object.prototype.hasOwnProperty.call(RGB_LOOKUP, name.toLowerCase())) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion from a newbie here, but instead of a Object.prototype.hasOwnProperty.call, would a simple object access that gives undefined be less scarry in this case?
*I put a ternary here, but keeping the if can be more readable too.

function colorKeywordToRGB(name) {
  const rgbKey = name.toLowerCase();

  return RGB_LOOKUP[rgbKey] ? `rgb(${RGB_LOOKUP[rgbKey].join(", ")})` : "";
}

@domenic domenic force-pushed the master branch 2 times, most recently from 2f07543 to 315b0ed Compare May 27, 2023 07:52
@domenic
Copy link
Member

domenic commented May 27, 2023

Unfortunately, I was unable to review this PR in a timely manner, since it's fairly large and I have less time for jsdom than I'd like. And now, a bunch of new web platform tests have been added, many of which fail. (Possibly due to changes in the dialog spec itself.) So we need someone to go through and figure out which ones we can pass, and update the implementation as appropriate.

I'm very sorry about this. I know it's a subpar contributor experience.

I'll try to help in a small way by pulling out the color-related changes into a separate PR, which I should be able to merge quickly on my own.

domenic added a commit that referenced this pull request May 27, 2023
Also attempts to implement more complex things like currentColor and inheritance and so on, but the test coverage for that is spotty...

Extracted from #3403 and updated to more closely follow the spec.

Co-authored-by: James Hoekzema <james.hoekzema@wwt.com>
domenic added a commit that referenced this pull request May 27, 2023
Also attempts to implement more complex things like currentColor and inheritance and so on, but the test coverage for that is spotty...

Extracted from #3403 and updated to more closely follow the spec.

Co-authored-by: James Hoekzema <james.hoekzema@wwt.com>
domenic added a commit that referenced this pull request May 27, 2023
Also attempts to implement more complex things like currentColor and inheritance and so on, but the test coverage for that is spotty...

Extracted from #3403 and updated to more closely follow the spec. Somewhat overlaps with #3060, but that is more complete.

Co-authored-by: James Hoekzema <james.hoekzema@wwt.com>
@delijah

This comment was marked as spam.

@AlexisCharp
Copy link

Hey,
Thanks for this PR, any plans to merge it soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants