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

Add cssText() method to adaptor and handle dynamic rules in HTML output. #1027

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

dpvc
Copy link
Member

@dpvc dpvc commented Nov 25, 2023

It turns out that when a stylesheet has dynamically added rules (like the ones MathJax produced for CHTML output when adaptiveCSS is true), those rules are not returned by innerHTML, outerHTML, or textContent. This makes it hard to obtain the CSS needed for HTML output in that case.

The PR adds a cssText() method to the adaptor class so that these rules will be included in the output. This can be used in place of innerHTML or textContent to get the list of rules when adaptiveCSS is being used.

@dpvc
Copy link
Member Author

dpvc commented Nov 25, 2023

The alternative would be to modify innerHTML, outerHTML, and textContent to include them, but that makes these function less compatible with what the browser actually does, and lead to confusion if these were used on a node containing a style node, like the head node, where the normal HTML behavior would still occur.

@dpvc dpvc requested a review from zorkow November 25, 2023 15:16
@dpvc dpvc added this to the v4.0 milestone Nov 25, 2023
Copy link
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

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

One typo.

ts/core/DOMAdaptor.ts Outdated Show resolved Hide resolved
Fix typo in comments

Co-authored-by: Volker Sorge <v.sorge@mathjax.org>
@dpvc dpvc merged commit ae389de into develop Nov 28, 2023
@dpvc dpvc deleted the adaptor-csstext branch November 28, 2023 13:39
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.

2 participants