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

[css-highlight-api]: Highlight constructor should accept 0 or more AbstractRanges instead of an optional sequence #4620

Closed
sanketj opened this issue Dec 20, 2019 · 3 comments

Comments

@sanketj
Copy link
Member

sanketj commented Dec 20, 2019

This can be achieved with the ... syntax, like append/prepend use here: https://dom.spec.whatwg.org/#parentnode. If more than one highlight needs to be added, they can be specified with additional parameters. This will avoid having to create a sequence when creating a Highlight with one range object.
So we would be able to do:

    let highlightRange = new Range();
    let highlight = new Highlight('example-highlight', highlightRange);
    CSS.highlights.add(highlight);

instead of:

    let highlightRange = new Range();
    let highlight = new Highlight('example-highlight', [highlightRange]);
    CSS.highlights.add(highlight);
@sanketj
Copy link
Member Author

sanketj commented Dec 20, 2019

@frivoal I'm happy to take care of this if you're okay with it.

@frivoal
Copy link
Collaborator

frivoal commented Dec 20, 2019

Thanks, that's an excellent suggestion, much better than what I had.

@frivoal
Copy link
Collaborator

frivoal commented Dec 20, 2019

It was an easy fix, so I just went ahead and did it. Sorry, I probably should have let you do it since you offered to and it's your suggestion… 🙇

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

No branches or pull requests

2 participants