Skip to content

Implement Range and Selection APIs#2719

Merged
domenic merged 2 commits into
jsdom:masterfrom
pmdartus:pmdartus/range
Dec 7, 2019
Merged

Implement Range and Selection APIs#2719
domenic merged 2 commits into
jsdom:masterfrom
pmdartus:pmdartus/range

Conversation

@pmdartus

Copy link
Copy Markdown
Member

Changes

This PR implements the Range and the Selection APIs. Sorry for this large PR, however the Range WPT tests are highly coupled with the Selection WPT tests and because of this wanted to make those 2 land at the same time.

Fix #317, fix #937

@domenic domenic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wow, good stuff. Only one concern with the Range constructor.

I admit not reviewing several of the very-long files in great detail, but scrolling through them they all seem very nicely structured, with lots of spec references, just in the awesome manner I've come to appreciate from your work. So I'm happy to merge this soon.

Comment thread lib/jsdom/browser/Window.js Outdated
});

// https://dom.spec.whatwg.org/#dom-range-range
function Range() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why implement this in this manner instead of using webidl2js?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not needed anymore, it was used to associate the Range with the Document. This is not needed anymore with the webidl2js constructor reform. The Document can now be extracted out of the newly introduced globalObject.

Comment thread lib/jsdom/living/nodes/Document-impl.js
Comment thread test/web-platform-tests/to-run.yaml
@domenic

domenic commented Nov 29, 2019

Copy link
Copy Markdown
Member

I re-ran the CI three times and it gives segfaults on the latest Node stable once we start hitting the dom/ranges tests. https://travis-ci.org/jsdom/jsdom/jobs/618664359 . So probably we shouldn't merge until we either find a workaround or Node.js fixes their upstream bug.

I haven't tried reproducing locally yet; I hope it isn't hard to do so :(.

@pmdartus

Copy link
Copy Markdown
Member Author

I was able to reproduce the issue locally against node 13.2.0.

@pmdartus

pmdartus commented Dec 7, 2019

Copy link
Copy Markdown
Member Author

The segfault was fixed with node 13.3.0. The CI is now passing and I also doubled checked locally just in case.

@rharriso

Copy link
Copy Markdown

I really appreciate this work. I'm refactoring a highlighting feature, so this will be extremely valuable to me.

@rpearce

rpearce commented Feb 23, 2020

Copy link
Copy Markdown

Thank you for this! Should it have also implemented Range.getClientRects()?

If range itself is fully supported, I believe this will open the door to automated color contrast accessibility testing via axe-core: https://github.com/dequelabs/axe-core/blob/104834fdc1fd09f5bb002ae48709f8939c0c7864/lib/rules/color-contrast-matches.js#L151.

@TimothyGu

Copy link
Copy Markdown
Member

There's probably no way for us to implement getClientRects, since we don't have a layout engine. See https://github.com/jsdom/jsdom#unimplemented-parts-of-the-web-platform.

@pmdartus
pmdartus deleted the pmdartus/range branch February 24, 2020 13:16
@rpearce

rpearce commented Feb 24, 2020

Copy link
Copy Markdown

@TimothyGu Thank you for the information!

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.

Implement DOM selection apis Implement Ranges and Traversal

5 participants