Skip to content

Commit e635bdf

Browse files
committed
dont invent a render semantic for preact
1 parent 44c8013 commit e635bdf

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

src/integrations/preact.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
* limitations under the License.
1212
*/
1313

14-
import { h, Component, render as preactRender } from 'preact';
14+
import { h, Component, render } from 'preact';
1515
import htm from '../htm';
1616

17-
export { h, Component };
17+
const html = htm.bind(h);
1818

19-
export function render(tree, parent) {
20-
preactRender(tree, parent, parent.firstElementChild);
21-
}
22-
23-
export const html = htm.bind(h);
19+
export { html, h, Component, render };

test/preact.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ describe('preact-html', () => {
4747
const fullHtml = '<div class="foo">\n\t\t\t\t\t<h1>Name: jason</h1>\n\t\t\t\t\t<p>Hello world!</p>\n\t\t\t\t\t<button>Click Me</button>\n\t\t\t\t\t<pre>Count: 0</pre>\n\t\t\t\t\txml-style end tags:\n\t\t\t\t\t<div>\n\t\tValue of hello: true\n\t\t\n\t</div>\n\t\t\t\t\texplicit end tags:\n\t\t\t\t\t<div>\n\t\tValue of hello: true\n\t\tsome children (count=0)\n\t</div>\n\t\t\t\t\timplicit end tags: (&lt;//&gt;)\n\t\t\t\t\t<div>\n\t\tValue of hello: true\n\t\tsome children (count=0)\n\t</div>\n\t\t\t\t\tsome text at the end\n\t\t\t\t</div>';
4848

4949
test('initial render', () => {
50-
render(html`<${Foo} name=jason />`, scratch);
50+
render(html`<${Foo} name=jason />`, scratch, scratch.firstElementChild);
5151
expect(scratch.innerHTML).toBe(fullHtml);
5252
});
5353

5454
test('rerenders in-place', () => {
55-
render(html`<${Foo} name=tom />`, scratch);
55+
render(html`<${Foo} name=tom />`, scratch, scratch.firstElementChild);
5656
expect(scratch.innerHTML).toBe(fullHtml.replace('jason', 'tom'));
5757
});
5858

@@ -69,19 +69,19 @@ describe('preact-html', () => {
6969
scratch.textContent = '';
7070

7171
const props = { a: 1, b: 2, c: 3 };
72-
render(html`<div ...${props} />`, scratch);
72+
render(html`<div ...${props} />`, scratch, scratch.firstElementChild);
7373
expect(scratch.innerHTML).toBe(`<div a="1" b="2" c="3"></div>`);
7474
scratch.innerHTML = '';
7575

76-
render(html`<div is-before="blah" ...${props} />`, scratch);
76+
render(html`<div is-before="blah" ...${props} />`, scratch, scratch.firstElementChild);
7777
expect(scratch.innerHTML).toBe(`<div is-before="blah" a="1" b="2" c="3"></div>`);
7878
scratch.innerHTML = '';
7979

80-
render(html`<div ...${props} is-after />`, scratch);
80+
render(html`<div ...${props} is-after />`, scratch, scratch.firstElementChild);
8181
expect(scratch.innerHTML).toBe(`<div a="1" b="2" c="3" is-after="true"></div>`);
8282
scratch.innerHTML = '';
8383

84-
render(html`<div is-before ...${props} is-after="blah" />`, scratch);
84+
render(html`<div is-before ...${props} is-after="blah" />`, scratch, scratch.firstElementChild);
8585
expect(scratch.innerHTML).toBe(`<div is-before="true" a="1" b="2" c="3" is-after="blah"></div>`);
8686
});
8787
});

0 commit comments

Comments
 (0)