Skip to content

Commit

Permalink
Support the template tag
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jan 19, 2025
1 parent cad1daf commit 3ad0f25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function diffElementNodes(
if (oldHtml) dom.innerHTML = '';

diffChildren(
dom,
newVNode.type === 'template' && dom.content ? dom.content : dom,

Check failure on line 528 in src/diff/index.js

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

Property 'content' does not exist on type 'PreactElement'.

Check failure on line 528 in src/diff/index.js

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

Property 'content' does not exist on type 'PreactElement'.
isArray(newChildren) ? newChildren : [newChildren],
newVNode,
oldVNode,
Expand Down
15 changes: 15 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ describe('render()', () => {
});
}

it('should support the <template> tag', () => {
function App() {
return (
<div>
<template>
<h2>this should show up</h2>
</template>
</div>
);
}

render(<App />, scratch);
console.log(scratch.firstChild.firstChild.content.innerHTML);
});

it('should not render when detecting JSON-injection', () => {
const vnode = JSON.parse('{"type":"span","children":"Malicious"}');
render(vnode, scratch);
Expand Down

0 comments on commit 3ad0f25

Please sign in to comment.