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

Preserve whitespace at each block boundaries #3059

Merged
merged 6 commits into from
Jun 21, 2019
Merged

Conversation

btk5h
Copy link
Contributor

@btk5h btk5h commented Jun 20, 2019

This should hopefully fix #713 and any of the duplicate issues people have filed.

This PR adds some logic that prevents whitespace from being trimmed at the end of each blocks.

@Conduitry
Copy link
Member

Awesome! This one has been bugging us for a while, as you can see :)

About the test, though: Could you write this as a runtime test instead of as a js one? Runtime tests check for specific compiled behavior, rather than checking for specific code, and so are much less brittle.

@btk5h
Copy link
Contributor Author

btk5h commented Jun 20, 2019

Is there an easy way to make runtime tests that are sensitive to whitespace differences?

The standard htmlEqual checks seem to ignore whitespace.

@Conduitry
Copy link
Member

You're right, sorry, the normalizeHtml function is more aggressive than I thought, and would defeat a test for this. I suppose you could do an assertion on the raw string and compare target.innerHTML against some regular expression, and not use assert.htmlEqual at all. It's ugly, but I think it's still better than testing for specific compiler output.

@Conduitry Conduitry merged commit fee4d35 into sveltejs:master Jun 21, 2019
@btk5h btk5h deleted the gh-713 branch June 21, 2019 20:08
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.

Whitespace inside elements is not being preserved inside loops
2 participants