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

Call same printChildren as for React in HTMLElement plugin #4275

Merged
merged 5 commits into from
Aug 23, 2017

Conversation

pedrottimark
Copy link
Contributor

@pedrottimark pedrottimark commented Aug 15, 2017

Summary

Fixes #3825

If highest priority is to accurately serialize HTML rendered by React or other frameworks:

  • Do not trim a content space at the beginning of a text node.
  • Do not trim a content newline (for example, in pre or textarea elements).
  • Do not filter out an empty text node.

For a while, I thought we could “have our cake and eat it too” for static-site HTML by removing newlines followed by even number of spaces with /\n+( {2})*/ pattern, but newline and indentation preceding span in syntax-highlighted pre is a counterexample.

Residue

  • serialize SVG elements from this plugin, because React can render them too
  • confusing indentation of multiline text node in lib/markup.js especially affecting HTML
  • last installment of README.md after Add Usage in Jest to pretty-format/README.md #4253 has been merged

Test plan

Local yarn test has one failure probably related to #4254 [have merged fix from master]

Updated existing tests to call createTextNode method:

  • supports an HTML element with attribute and text content
  • supports an element with text content
  • supports nested elements with attribute and text content

Updated existing tests to specify improved formatting:

  • supports non-empty text node
  • supports comment node
  • supports maxDepth option

Added fail-first tests to specify improved formatting:

  • supports empty text node
  • supports multiline text node in pre
  • supports multiline text node preceding span in pre
  • supports multiline text node in textarea element

Added pass-first tests to specify existing formatting:

  • supports nested elements with attribute and text content

@pedrottimark pedrottimark changed the title Call same printChildren as for React in HTMLElement plugins Call same printChildren as for React in HTMLElement plugin Aug 15, 2017
@pedrottimark pedrottimark mentioned this pull request Aug 23, 2017
6 tasks
@cpojer cpojer merged commit 27c5a97 into jestjs:master Aug 23, 2017
@pedrottimark pedrottimark deleted the html-element-children branch August 23, 2017 14:20
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reconsider “unnecessary” whitespace in HTMLElement plugin
3 participants