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

detect, use and respond with document or fragement html #34

Merged

Conversation

thescientist13
Copy link
Member

@thescientist13 thescientist13 commented May 20, 2022

Related Issue

resolves #30

Summary of Changes

  1. Best guess and standardize on HTML parsing and responding
  2. Specifically test for these document tags in tests

Observations

So I see cheerio has to do something like this by accounting for <head>, <html>, and <body> tags, and hopefully this works because parse will automatically do this if using parse, and parseFragment will actually strip them out if they are. 😵

Also another vote for #14 because JSDOM will also infer these tags if they are there or not

(Note that jsdom will parse the HTML you pass it just like a browser does, including implied <html>, <head>, and <body> tags.)

which is why I had to hack in this test because the specs were passing whether I was using parse or parseFragment. If we can bypass all that and just test HTML <> HTML directly. 🤞


Maybe we should allow an isDocument option, to avoid the confusion and let user's override / specify themselves? But it would only be for top level, in theory, so if it is present, only render the top as parse or parseFragment, and the rest as parseFragment.

@thescientist13 thescientist13 added the enhancement Improvement to existing functionality label May 20, 2022
@thescientist13 thescientist13 merged commit eb9eb1d into master May 27, 2022
@thescientist13 thescientist13 deleted the enhancment/issue-30-standardize-render-api-respone-html branch May 27, 2022 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

standardize HTML response between renderToString and renderFromHTML
1 participant