Skip to content

Commit

Permalink
feat: enables jsx fragments using pragmaFrag option and Fragment import
Browse files Browse the repository at this point in the history
  • Loading branch information
geotrev committed Jun 1, 2022
1 parent 6268768 commit 08cecc8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
7 changes: 6 additions & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"babelrcRoots": [".", "packages/*"],
"plugins": [["@babel/plugin-transform-react-jsx", { "pragma": "jsx" }]],
"plugins": [
[
"@babel/plugin-transform-react-jsx",
{ "pragma": "jsx", "pragmaFrag": "Fragment" }
]
],
"presets": ["@babel/preset-env"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "bulba",
"name": "bulba-web-components",
"version": "0.14.0-alpha.1",
"private": true,
"type": "module",
Expand Down
22 changes: 13 additions & 9 deletions packages/jsx/src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ const createEmptyVNode = (element, Internal) =>
},
})

const patch = init([
classModule,
propsModule,
styleModule,
eventListenersModule,
attributesModule,
datasetModule,
denyUnlessSigned,
])
const patch = init(
[
classModule,
propsModule,
styleModule,
eventListenersModule,
attributesModule,
datasetModule,
denyUnlessSigned,
],
undefined,
{ experimental: { fragments: true } }
)

function getRenderState(element) {
return sign(transform(element[External.render]()))
Expand Down
18 changes: 10 additions & 8 deletions preview/jsx/fixtures/render-schedule-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BulbaElement, register } from "@bulba/element"
import { Renderer, jsx } from "@bulba/jsx"
import { Renderer, jsx, Fragment } from "@bulba/jsx"

export class RenderScheduleTest extends BulbaElement(Renderer) {
static get properties() {
Expand Down Expand Up @@ -47,13 +47,15 @@ export class RenderScheduleTest extends BulbaElement(Renderer) {
borderColor: this.borderColor,
}}
>
<p>Render count: {this.count}</p>
<p className="label" style={{ color: this.labelColor }}>
This is a scheduling test.
<br />
It should have one render per button press, despite having multiple
property updates.
</p>
<>
<p>Render count: {this.count}</p>
<p className="label" style={{ color: this.labelColor }}>
This is a scheduling test.
<br />
It should have one render per button press, despite having multiple
property updates.
</p>
</>
<button on-click={this.handleClick}>Click to update</button>
</div>
)
Expand Down

0 comments on commit 08cecc8

Please sign in to comment.