Skip to content

Commit c0c9ec5

Browse files
committed
revert preact changes
1 parent c8d1b66 commit c0c9ec5

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build:main": "microbundle src/index.mjs -f es,umd --no-sourcemap --target web",
1111
"build:preact": "microbundle src/integrations/preact.mjs -o preact/index.js -f es,umd --no-sourcemap --target web",
1212
"build:babel": "microbundle src/babel.mjs -o babel/index.js -f es,cjs --target node --no-compress --no-sourcemap",
13-
"test": "eslint src test && jest test"
13+
"test": "eslint src/**/*.mjs test && jest test"
1414
},
1515
"eslintConfig": {
1616
"extends": "developit",

src/integrations/preact.mjs

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

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

17+
function render(tree, parent) {
18+
preactRender(tree, parent, parent.firstElementChild);
19+
}
20+
1721
const html = htm.bind(h);
1822

19-
export { html, h, Component, render };
23+
export { h, html, render, Component };

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, scratch.firstElementChild);
50+
render(html`<${Foo} name=jason />`, scratch);
5151
expect(scratch.innerHTML).toBe(fullHtml);
5252
});
5353

5454
test('rerenders in-place', () => {
55-
render(html`<${Foo} name=tom />`, scratch, scratch.firstElementChild);
55+
render(html`<${Foo} name=tom />`, scratch);
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, scratch.firstElementChild);
72+
render(html`<div ...${props} />`, scratch);
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, scratch.firstElementChild);
76+
render(html`<div is-before="blah" ...${props} />`, scratch);
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, scratch.firstElementChild);
80+
render(html`<div ...${props} is-after />`, scratch);
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, scratch.firstElementChild);
84+
render(html`<div is-before ...${props} is-after="blah" />`, scratch);
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)