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

Change signature of Prism.highlight{Element,All,AllUnder} #3528

Closed
RunDevelopment opened this issue Aug 19, 2022 · 4 comments
Closed

Change signature of Prism.highlight{Element,All,AllUnder} #3528

RunDevelopment opened this issue Aug 19, 2022 · 4 comments
Milestone

Comments

@RunDevelopment
Copy link
Member

RunDevelopment commented Aug 19, 2022

Motivation
Similar to #3416, it would be nice to have all optional arguments of Prism.highlight{Element,All,AllUnder} in an options dictionary.

Description
So the new signature should be:

(Updated after the below discussion)

interface HighlightAllOptions {
  root?: Element;
  async?: boolean;
  callback?: (element: Element) => void;
}
function highlightAll(options?: HighlightAllOptions) { ... } 

interface HighlightElementOptions {
  async?: boolean;
  callback?: (element: Element) => void;
}
function highlightElement(element: T, options?: HighlightElementOptions) { ... }

Example usage:

Prism.highlightAll({ root: document.querySelector("#page") })

Thoughts? @LeaVerou @Golmote @mAAdhaTTah @JaKXz

@RunDevelopment RunDevelopment added this to the 2.0 milestone Aug 19, 2022
@LeaVerou
Copy link
Member

Yes, agreed with removing highlightAllUnder() and making it an option in highlightAll(). Wrt naming, I think container is more common. Maybe also root?

@JaKXz
Copy link
Collaborator

JaKXz commented Aug 19, 2022

I think root is probably the most ubiquitous / broadly accepted :)

@RunDevelopment
Copy link
Member Author

Agreed. root sounds good.

@RunDevelopment
Copy link
Member Author

Implemented in v2.

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

3 participants