handlebars-lang / handlebars.js

Minimal templating on steroids.
http://handlebarsjs.com
MIT License
17.96k stars 2.04k forks source link

Node 18 Whitespace + Self-closing Tags #1941

Closed mcblum closed 1 year ago

mcblum commented 1 year ago

Hello!

We're in the process of upgrading our app to use Node 18. When I did the upgrade, all of the tests failed. Looking into it, it looks like there's some difference where all of the whitespace is being collapsed and the self-closing tags stripped out. So <meta /> is becoming <meta>.

I see some recent commits for testing with Node 18, but I'm wondering if it's fully supported or if anyone else has seen this?

Thanks!

jaylinski commented 1 year ago

Hm... the tests seem to run fine, even with Node 20:

https://github.com/handlebars-lang/handlebars.js/actions/runs/4997611619/jobs/8952151271

Also: it would be weird if the Node version somehow had influence on how Handlebars handles whitespace.

Did you upgrade handlebars or did it stay the same in your lock-file?

mcblum commented 1 year ago

@jaylinski I thought the same thing! I did not, it stayed exactly the same in the lockfile, as did all its dependencies. That was surprising to me. I did learn that actually the HTML5 spec does not require self-closing tags because it considers those elements "void", but there are a couple other strange things happening, too, like the CSS color hex codes are being transformed to all uppercase. Something is definitely weird, but I can't seem to figure out why.

jaylinski commented 1 year ago

Maybe there is another post- or pre-processing step in your setup that now changes your rendered HTML?