developit / vhtml

Render JSX/Hyperscript to HTML strings, without VDOM 🌈

Home Page:http://npm.im/vhtml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rendering HTML entities

ryaninvents opened this issue · comments

vhtml renders “ as “, which causes the source string to appear in the output.

It would be helpful if entities in the "quasis" of the template string were left alone, and interpolated string values were escaped:

// Source
const copyright = '© 2021';
return html`<div>&ldquo;${copyright}&rdquo;</div>`;

// Rendered output
<div>&ldquo;&amp;copy;2021&rdquo;</div>

Hm, started a PR but the problem doesn't seem to be in this package. Definitely a problem with my specific use case.

	it("should not sanitize HTML entities", () => {
		expect(
			<div>
				&copy;
				<em>allowed</em>
			</div>
		).to.equal(`<div>©<em>allowed</em></div>`);
	});

HI @ryaninvents, I am hitting the same issue. How did you overcome your situation?

I don't recall whether I fixed it in the project itself... The reason I closed the issue is because I created a minimal test case to demonstrate the issue, but the test case behaved as expected. I think there was another layer in my application trying to perform encoding, so it was getting applied twice.