Skip to content

Commit 940fa6c

Browse files
authored
Merge pull request #130 from ryansolid/next
Revamp Reactive System and update to DOM Expressions
2 parents fd888a8 + 630f6fc commit 940fa6c

54 files changed

Lines changed: 5215 additions & 4491 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
# Changelog
2+
## 0.17.0 - 2020-03-??
3+
A lot of consolidation in preparation for release candidate
4+
* Big refactor of core reactive system and render list reconciler
5+
* Significantly smaller reducing core by atleast 3kb minified
6+
* Better handling of nested reactive nodes in Fragments
7+
* Update SSR mechanisms, added progressive event hydration, created repo for SSR environment (`solid-ssr`)
8+
* `@once` compiler hint to statically bind values
9+
* Better wrapping hueristics for booleans and ternaries in JSX
10+
11+
Breaking Changes
12+
* Removed `transform` prop from control flow. Idiomatic approach is to make a HOC for transformations of this nature.
13+
* Removed selectWhen/selectEach control flow transforms.
14+
* Changed event system
15+
* `on____` prop to stop differentiating on case. Super confusing.Instead will try to delegate unless unable. Made TypeScript all CamelCase (although technically both forms behave identically)
16+
* Removed `model` event delegation approach. Instead to create bound event use array: `onClick={[handler, row.id]}`. Inspired by Inferno's `linkEvent` helper.
17+
* Renamed `events` prop to `on` prop
18+
* Added `onCapture` prop for capture events
19+
220
## 0.16.0 - 2020-01-14
321
Big changes to experimental features:
422
* New resource API `createResource` and `createResourceState` to replace `loadResource`. These are built to prioritize read capabilities and simplify implementation.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ The easiest way to get setup is add `babel-preset-solid` to your .babelrc, or ba
139139

140140
Remember even though the syntax is almost identical, there are significant differences between how Solid's JSX works and a library like React. Refer to [JSX Rendering](../master/documentation/rendering.md) for more information.
141141

142-
Alternatively in non-compiled environments you can use Tagged Template Literals [Lit DOM Expressions](https://github.com/ryansolid/lit-dom-expressions) or even HyperScript with [Hyper DOM Expressions](https://github.com/ryansolid/hyper-dom-expressions).
142+
Alternatively in non-compiled environments you can use Tagged Template Literals [Lit DOM Expressions](https://github.com/ryansolid/dom-expressions/tree/master/packages/lit-dom-expressions) or even HyperScript with [Hyper DOM Expressions](https://github.com/ryansolid/dom-expressions/tree/master/packages/hyper-dom-expressions).
143143

144144
For convenience Solid exports interfaces to runtimes for these as:
145145

@@ -196,11 +196,11 @@ Remember you still need to install the library separately for these to work.
196196
Functional Reactive Programming extensions to Solid.js.
197197
- [DOM Expressions](https://github.com/ryansolid/dom-expressions)
198198
The renderer behind Solid.js that enables lightning fast fine grained performance.
199-
- [Babel Plugin JSX DOM Expressions](https://github.com/ryansolid/babel-plugin-jsx-dom-expressions)
199+
- [Babel Plugin JSX DOM Expressions](https://github.com/ryansolid/dom-expressions/tree/master/packages/babel-plugin-jsx-dom-expressions)
200200
Babel plugin that converts JSX to DOM Expressions.
201-
- [Lit DOM Expressions](https://github.com/ryansolid/lit-dom-expressions)
201+
- [Lit DOM Expressions](https://github.com/ryansolid/dom-expressions/tree/master/packages/lit-dom-expressions)
202202
Tagged Template Literal API for DOM Expressions.
203-
- [Hyper DOM Expressions](https://github.com/ryansolid/hyper-dom-expressions)
203+
- [Hyper DOM Expressions](https://github.com/ryansolid/dom-expressions/tree/master/packages/hyper-dom-expressions)
204204
HyperScript API for DOM Expressions.
205205
- [Solid Hot Loader](https://github.com/ryansolid/solid-hot-loader)
206206
Webpack Loader for HMR for Solid Components.

documentation/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Creates a new resource signal that can hold a async resource. Resources when rea
3636

3737
Creates a new Resource State object. Similar to normal state except each immediate property is a resource.
3838

39-
### `onCleanup((final: boolean) => <code>)`
39+
### `onCleanup(() => <code>)`
4040

4141
Registers a cleanup methodthat executes on disposal or recalculation of the current context.
4242

documentation/rendering.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Rendering involves precompilation of JSX templates into optimized native js code
88

99
This approach both is more performant and produces less code then creating each element one by one with document.createElement.
1010

11-
More documentation is available at: [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/babel-plugin-jsx-dom-expressions)
11+
More documentation is available at: [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/master/packages/babel-plugin-jsx-dom-expressions)
1212

1313
### Note on attribute binding order
1414

@@ -32,9 +32,25 @@ render(() => <App />, document.getElementById("main"));
3232

3333
## Events
3434

35-
on**\_** properties get added (addEventListener) as event handlers on the element. Camel Case events will be delegated by default and the second argument will be the model property or (nearest parent's). Use all lowercase for directly bound native events.
35+
`on_____` handlers are event handlers expecting a function. The compiler will delegate events where possible (Events that can be composed and bubble) else it will fall back to Level 1 spec "on**\_**" events.
3636

37-
If you need to use non-lowercase or hyphenated event names use the events binding.
37+
If you wish to bind a value to your delegated event pass an array handler instead and the second argument will be passed to your event handler as the first argument (the event will be second). This can improve performance in large lists.
38+
39+
```jsx
40+
function handler(itemId, e) {/*...*/}
41+
42+
<ul>
43+
<For each={state.list}>{item => <li onClick={[handler, item.id]} />}</For>
44+
</ul>
45+
```
46+
47+
This delegation solution works with Web Components and the Shadow DOM as well if the events are composed. That limits the list to custom events and most UA UI events like onClick, onKeyUp, onKeyDown, onDblClick, onInput, onMouseDown, onMouseUp, etc..
48+
49+
To allow for casing to work all custom events should follow the all lowercase convention of native events. If you want to use different event convention (or use Level 3 Events "addEventListener") use the "on" or "onCapture" binding.
50+
51+
```jsx
52+
<div on={{ "Weird-Event": e => alert(e.detail) }} />
53+
```
3854

3955
## Control Flow
4056

@@ -123,45 +139,53 @@ _Note these are designed to handle more complex scenarios like Component inserti
123139
Refs come in 2 flavours. `ref` which directly assigns the value, and `forwardRef` which calls a callback `(ref) => void` with the reference. To support forwarded properties on spreads, both `ref` and `forwardRef` are called as functions.
124140

125141
### `ref`
142+
126143
```jsx
127144
function MyComp() {
128145
let myDiv;
129146
setTimeout(() => console.log(myDiv.clientWidth));
130-
return <div ref={myDiv} />
147+
return <div ref={myDiv} />;
131148
}
132149
```
150+
133151
On a native intrinsic element as the element executes the provided variable will be assigned. This form usually is used in combination with `setTimeout` (same timing as React's `useEffect`) or `afterEffects`(same timing as React's `useLayoutEffect`) to do work after the component has mounted. Like do a DOM measurement or attach DOM plugins etc...
134152

135153
When applied to a Component it acts similarly but also passes a prop in that is a function that is expected to be called with a ref to forward the ref (more on this in the next section):
154+
136155
```jsx
137156
function App() {
138157
let myDiv;
139158
setTimeout(() => console.log(myDiv.clientWidth));
140-
return <MyComp ref={myDiv} />
159+
return <MyComp ref={myDiv} />;
141160
}
142161
```
143162

144163
### `forwardRef`
164+
145165
This form expects a function like React's callback refs. Original use case is like described above:
166+
146167
```jsx
147168
function MyComp(props) {
148-
return <div forwardRef={props.ref} />
169+
return <div forwardRef={props.ref} />;
149170
}
150171

151172
function App() {
152173
let myDiv;
153174
setTimeout(() => console.log(myDiv.clientWidth));
154-
return <MyComp ref={myDiv} />
175+
return <MyComp ref={myDiv} />;
155176
}
156177
```
178+
157179
You can also apply `forwardRef` on a Component:
180+
158181
```jsx
159182
function App() {
160-
return <MyComp forwardRef={ref => console.log(ref.clientWidth)} />
183+
return <MyComp forwardRef={ref => console.log(ref.clientWidth)} />;
161184
}
162185
```
186+
163187
This just passes the function through as `props.ref` again and work similar to the example above except it would run synchronously during render. You can use this to chain as many `forwardRef` up a Component chain as you wish.
164188

165189
## Server Side Rendering (Experimental)
166190

167-
See [solid-ssr](https://github.com/ryansolid/solid/blob/master/packages/solid-ssr)
191+
See [solid-ssr](https://github.com/ryansolid/solid/blob/master/packages/solid-ssr)

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"packages": [
33
"packages/*"
44
],
5-
"version": "0.16.14"
5+
"version": "0.17.0-beta.3"
66
}

0 commit comments

Comments
 (0)