You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 8, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+28-25
Original file line number
Diff line number
Diff line change
@@ -15,22 +15,24 @@ This plugin treats all lowercase tags as html elements and mixed cased tags as C
15
15
16
16
In general JSX Attribute Expressions are treated as properties by default, with exception of hyphenated(-) ones that will always be set as attributes on the DOM element. Plain string attributes(Non expression, no {}) will be treated as attributes.
17
17
18
-
<b>For dynamic expressions that should be wrapped in a computation for partial re-render use inner parenthesis in the expression ```{( )}```.</b>
18
+
This library uses a heuristic whether to dynamic wrap expressions based on if they contain function calls or property access. Simple literals and variable expressions won't be wrapped.
The use of cloneNode improves repeat insert performance and precompilation reduces the number of references to the minimal traversal path. This is a basic example which doesn't leverage event delegation or any of the more advanced features described below.
61
65
@@ -78,9 +82,6 @@ Boolean to indicate whether to enable automatic event delegation on camelCase.
78
82
### contextToCustomElements
79
83
Boolean indicates whether to set current render context on Custom Elements and slots. Useful for seemless Context API with Web Components.
80
84
81
-
### alwaysWrap
82
-
Removes the need for `{( )}` syntax. All expressions will be dynamic. This can lead to severe performance degradation. Use at your own risk.
83
-
84
85
### alwaysCreateComponents
85
86
Always use createComponent method instead of just calling the function. Needed to support class components.
86
87
@@ -112,7 +113,7 @@ These will be treated as event handlers expecting a function. All lowercase are
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..
@@ -126,7 +127,7 @@ Important:
126
127
127
128
This takes an object and assigns all the keys as classes which are truthy.
Spreads let you pass multiple props at once. If you wish dynamic updating remember to wrap with a parenthesis:
141
+
Spreads let you pass multiple props at once:
141
142
142
143
```jsx
143
-
<div {...static} {...(dynamic)} />
144
+
<div {...static} />
144
145
```
145
146
146
147
Keep in mind given the independent nature of binding updates there is no guarantee of order using spreads at this time. It's under consideration.
147
148
148
149
## Components
149
150
150
-
Components are just Capital Cased tags. The same rules around dynamic wrapping apply. Instead of wrapping with computation dynamic props will just be getter accessors. * Remember property access triggers so don't destructure outside of computations.
151
+
Components are just Capital Cased tags. Instead of wrapping with computation dynamic props will just be getter accessors. * Remember property access triggers so don't destructure outside of computations unless you intend the content to be static.
151
152
152
153
```jsx
153
-
constMyComp=props=> (
154
-
<>
155
-
<div>{( props.param )}</div>
156
-
<div>{ props.static }</div>
154
+
constMyComp=props=> {
155
+
conststaticProp=props.other;
156
+
return<>
157
+
<div>{ props.param }</div>
158
+
<div>{ staticProp }</div>
157
159
</>
158
-
);
160
+
};
159
161
160
-
<MyComp param={(dynamic() )} other={ static } />
162
+
<MyComp param={ dynamic() } other={ static } />
161
163
```
162
164
163
-
Components may have children. This is available as props.children. It may be a node, a function, or a string, or an array of the aforementioned. Non-expression children like DOM nodes are set to evaluate lazily (upon access by default). For single expressions you must use {( )} to have the same behaviour.
165
+
Components may have children. This is available as props.children. It may be a node, a function, or a string, or an array of the aforementioned. Non-expression children like DOM nodes are set to evaluate lazily (upon access by default).
164
166
165
167
## Fragments
166
168
167
169
This plugin also supports JSX Fragments with `<></>` notation. These will be compiled to arrays. The fragment syntax provides the convenience of being able to use the template syntax to wrap expressions.
168
170
169
171
## SVG
170
172
171
-
There is basic SVG support with this library. Most element/attributes should work but no support for namespaces yet.
173
+
There is basic SVG support with this library. Most element attributes should work but no support for namespaces yet.
174
+
172
175
## Acknowledgements
173
176
174
177
The concept of using JSX to DOM instead of html strings and context based binding usually found in these libraries was inspired greatly by [Surplus](https://github.com/adamhaile/surplus).
0 commit comments