Skip to content

Commit 82fb177

Browse files
committed
Fixed typo (ref name) and added basic test
1 parent 5aecc04 commit 82fb177

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

esm/rabbit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ const parseSVG = create(parser(true));
1111
* @param {Hole} hole
1212
* @returns {Node}
1313
*/
14-
export const unroll = (cache, { s: stack, t: template, v: values }) => {
14+
export const unroll = (cache, { s: svg, t: template, v: values }) => {
1515
if (values.length && cache.s === empty) cache.s = [];
1616
unrollValues(cache, values);
1717
if (cache.t !== template) {
18-
const { n: node, d: details } = (stack ? parseSVG : parseHTML)(template, values);
18+
const { n: node, d: details } = (svg ? parseSVG : parseHTML)(template, values);
1919
cache.t = template;
2020
cache.n = node;
2121
cache.d = details;

test/index.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
6+
<title>udom</title>
7+
<script type="module">
8+
const testUHTML = () => import('./uhtml.js').then(({ render, html }) => {
9+
console.time('parse uhtml');
10+
render(uhtml, html`<div class=${'test'}>${'content'}</div>`);
11+
console.timeEnd('parse uhtml');
12+
});
13+
14+
// testUHTML();
15+
16+
import('../keyed.js').then(async ({ render, html, svg, htmlFor }) => {
17+
const { html: htmlNode } = await import('../node.js');
18+
let i = 0;
19+
const same = () => htmlFor(document, 'key')`<div class=${'test'} data=${{a: i}}>${'content ' + i}</div>`;
20+
const diff = () => html`<div class=${'test'} data=${{a: i}}>${'content'}</div>`;
21+
const node = () => htmlNode`<div class=${'test'} data=${{a: i}}>${'content'}</div>`;
22+
const test = () => {
23+
i++;
24+
render(udomunderstand, html`
25+
<div>
26+
${diff()}
27+
${[
28+
same(),
29+
diff(),
30+
diff(),
31+
node(),
32+
diff(),
33+
diff(),
34+
].concat(Math.random() < .5 ? [diff(), diff()] : [])}
35+
</div>
36+
`);
37+
};
38+
test();
39+
render(uhtml, html`<button>a</button><button>b</button>`);
40+
setInterval(test, 250);
41+
console.assert(same() === same());
42+
console.assert(diff() !== diff());
43+
});
44+
</script>
45+
</head>
46+
<body>
47+
<div id="udomunderstand"></div>
48+
<div id="uhtml"></div>
49+
</body>
50+
</html>

types/rabbit.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function unroll(cache: import("./literals.js").Cache, { s: stack, t: template, v: values }: Hole): Node;
1+
export function unroll(cache: import("./literals.js").Cache, { s: svg, t: template, v: values }: Hole): Node;
22
/**
33
* Holds all details needed to render the content on a render.
44
* @constructor

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy