Skip to content

Commit be6f19d

Browse files
committed
🐛 fix spread with events
1 parent 08d674e commit be6f19d

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

loaders/add-source-to-node.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ module.exports = function (source) {
1313
if (path.parent.type === 'JSXAttribute') {
1414
if (path.node.name.startsWith('on')) {
1515
const element = path.findParent((p) => p.type === 'JSXOpeningElement' && p.node.attributes)
16-
const hasSource = element.node.attributes.find((a) => a.name.name === 'source')
16+
const hasSource = element.node.attributes.find((a) => {
17+
return a.type === 'JSXAttribute' && a.name.name === 'source'
18+
})
1719
if (!hasSource) {
1820
const start = element.node.attributes[0].start
1921
uniquePositions.add(start)

tests/src/RenderableComponent.njs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class RenderableComponent extends Nullstack {
2828
render({ params }) {
2929
const list = params.shortList ? [1, 2, 3] : [1, 2, 3, 4, 5, 6]
3030
const html = '<a href="/"> Nullstack </a>'
31+
const props = { disabled: true, 'aria-label': 'props' }
3132
return (
3233
<div class="RenderableComponent">
3334
<Falsy />
@@ -56,16 +57,17 @@ class RenderableComponent extends Nullstack {
5657
</head>
5758
{!!params.condition && <div class="condition"> conditionally rendered div </div>}
5859
<a params={{ shortList: true }} class="short-list">
59-
{' '}
60-
long list{' '}
60+
long list
6161
</a>
6262
<a params={{ condition: true }} class="true-condition">
63-
{' '}
64-
long list{' '}
63+
long list
6564
</a>
6665
<div data-condition={!!params.condition} />
6766
<div data-short-list={!!params.shortList} />
6867
<div data-name={this.name} />
68+
<button {...props} onclick={() => {}}>
69+
props
70+
</button>
6971
</div>
7072
)
7173
}

tests/src/RenderableComponent.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ describe('RenderableComponent ?condition=true', () => {
115115
const element = await page.$('div.element')
116116
expect(element).toBeTruthy()
117117
})
118+
119+
test('elements can spread props and have named attributes', async () => {
120+
const element = await page.$('[disabled][aria-label="props"]')
121+
expect(element).toBeTruthy()
122+
})
118123
})
119124

120125
describe('RenderableComponent ?shortList=true', () => {

0 commit comments

Comments
 (0)