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

Fixes #2714: Provide non-decoded text to parse consumers #2859

Merged
merged 1 commit into from
May 26, 2019

Conversation

RedHatter
Copy link
Contributor

Adds a raw property to text nodes with decoded html entities set to the original data.

@RedHatter RedHatter changed the title Fixes #2714 Fixes #2714: Provide non-decoded text to parse consumers May 24, 2019
@Rich-Harris
Copy link
Member

Thanks for the PR. For the sake of consistency, would it be better if chunk.raw was always set, rather than only when it differs from the decoded value?

Purely out of curiosity, what motivated this?

@jarrodldavis
Copy link

@Rich-Harris This fixes #2714 so that prettier-plugin-svelte preserves HTML entities when it formats and prints Svelte templates (see also sveltejs/prettier-plugin-svelte#29)

@Rich-Harris
Copy link
Member

Ah, of course — the issue was already referenced 🙈

@Rich-Harris Rich-Harris merged commit ef59c32 into sveltejs:master May 26, 2019
@Rich-Harris
Copy link
Member

I took the liberty of changing the behaviour in b7f9c9c so that .raw is always added to text nodes. I find that it pays off in the end to make sure these things always behave the same way, even if it results in a larger AST

Thank you

@jarrodldavis
Copy link

If AST size is an issue, would it be better for raw to be opt-in using an option given to parse?

@Rich-Harris
Copy link
Member

That's what I mean, I don't think it is an issue — it's rare that you'd need to serialize the AST, and memory consumption doesn't really matter since compilation happens at build time. If it were important to keep the AST small I reckon we'd want to change the design in more radical ways

@RedHatter RedHatter deleted the raw-entities branch May 26, 2019 13:30
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.

3 participants