Skip to content

Commit 0ccf840

Browse files
committed
chore: format
1 parent 6830a48 commit 0ccf840

File tree

6 files changed

+31
-39
lines changed

6 files changed

+31
-39
lines changed

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ changelog.md
66
coverage
77
build
88
dist
9+
10+
test/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# etch-solid
2+
23
fast DOM library - etch with solid backend
34

45
![Build Status (Github Actions)](https://github.com/atom-ide-community/etch-solid/workflows/CI/badge.svg)

babel.config.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
}
99
]
1010
],
11-
"plugins": [
12-
"solid-styled-jsx/babel"
13-
],
11+
"plugins": ["solid-styled-jsx/babel"],
1412
"parserOpts": {}
1513
}

examples/hello-world/.babelrc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
2-
"presets": [
3-
"babel-preset-solid"
4-
],
5-
"plugins": [
6-
"solid-styled-jsx/babel"
7-
],
2+
"presets": ["babel-preset-solid"],
3+
"plugins": ["solid-styled-jsx/babel"],
84
"parserOpts": {}
95
}

examples/hello-world/index.jsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
import * as etch from '../../dist/index';
1+
import * as etch from "../../dist/index"
22

33
class MyComponent {
44
constructor(props, children) {
5-
this.props = props;
6-
etch.initialize(this);
5+
this.props = props
6+
etch.initialize(this)
77
}
88

99
render() {
10-
return <div>{this.props.greeting} World!</div>;
10+
return <div>{this.props.greeting} World!</div>
1111
}
1212

1313
hello() {
14-
console.log("hello");
14+
console.log("hello")
1515
}
1616

1717
update(newProps) {
18-
this.hello();
18+
this.hello()
1919
if (this.props.greeting !== newProps.greeting) {
20-
this.props.greeting = newProps.greeting;
20+
this.props.greeting = newProps.greeting
2121
}
2222
}
2323
}
2424

25-
const instance = new MyComponent({ greeting: "Hello" });
25+
const instance = new MyComponent({ greeting: "Hello" })
2626

27-
const app = document.getElementById("app");
27+
const app = document.getElementById("app")
2828

2929
// using element
30-
app.appendChild(instance.element);
30+
app.appendChild(instance.element)
3131

3232
setTimeout(() => {
33-
instance.update({ greeting: "Hi" });
34-
console.log("updated");
35-
}, 1000);
33+
instance.update({ greeting: "Hi" })
34+
console.log("updated")
35+
}, 1000)

src/index.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { createState, createRoot, produce } from "solid-js";
2-
1+
import { createState, createRoot, produce } from "solid-js"
32

43
type EtchSolidElement = any
54
interface EtchSolidComponent {
@@ -12,35 +11,31 @@ interface EtchSolidComponent {
1211

1312
// etch.initialize
1413
export function initialize(component: EtchSolidComponent) {
15-
1614
const $originUpdate = component.update,
17-
$originDestroy = component.destroy;
15+
$originDestroy = component.destroy
1816

1917
// handle the changes in the states
20-
let dispose: () => void;
21-
const d = Object.getOwnPropertyDescriptors(component.__proto__);
22-
const [$state, setState] = createState(
23-
Object.assign(Object.create(Object.prototype, d), component)
24-
);
18+
let dispose: () => void
19+
const d = Object.getOwnPropertyDescriptors(component.__proto__)
20+
const [$state, setState] = createState(Object.assign(Object.create(Object.prototype, d), component))
2521

2622
// handle updating
2723
function update(...args: any[]) {
28-
setState(produce((s) => $originUpdate.call(s, ...args)));
24+
setState(produce((s) => $originUpdate.call(s, ...args)))
2925
}
3026

3127
// handle destroying
3228
function destroy() {
33-
$originDestroy && $originDestroy.call($state);
34-
dispose();
29+
$originDestroy && $originDestroy.call($state)
30+
dispose()
3531
}
3632

37-
3833
// add update, destroy, and setState to the component
39-
Object.assign(component, { update, destroy, setState });
34+
Object.assign(component, { update, destroy, setState })
4035

4136
// element property
4237
createRoot((disposer) => {
43-
dispose = disposer;
44-
component.element = component.render.call($state);
45-
});
38+
dispose = disposer
39+
component.element = component.render.call($state)
40+
})
4641
}

0 commit comments

Comments
 (0)