Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client/instanceProxyHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ const instanceProxyHandler = {
try {
result = target[name].call(proxy, scopedContext)
} catch (error) {
context.catch && context.catch(error)
if (context.catch) {
context.catch(error)
} else {
throw error
}
return null
}
if (result instanceof Promise) {
Expand Down
4 changes: 3 additions & 1 deletion loaders/add-source-to-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module.exports = function (source) {
if (path.parent.type === 'JSXAttribute') {
if (path.node.name.startsWith('on')) {
const element = path.findParent((p) => p.type === 'JSXOpeningElement' && p.node.attributes)
const hasSource = element.node.attributes.find((a) => a.name.name === 'source')
const hasSource = element.node.attributes.find((a) => {
return a.type === 'JSXAttribute' && a.name.name === 'source'
})
if (!hasSource) {
const start = element.node.attributes[0].start
uniquePositions.add(start)
Expand Down
4 changes: 3 additions & 1 deletion server/printError.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import context from './context'

export default function (error) {
context.catch && context.catch(error)
if (context.catch) {
context.catch(error)
}
const lines = error.stack.split(`\n`)
let initiator = lines.find((line) => line.indexOf('Proxy') > -1)
if (initiator) {
Expand Down
10 changes: 6 additions & 4 deletions tests/src/RenderableComponent.njs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class RenderableComponent extends Nullstack {
render({ params }) {
const list = params.shortList ? [1, 2, 3] : [1, 2, 3, 4, 5, 6]
const html = '<a href="/"> Nullstack </a>'
const props = { disabled: true, 'aria-label': 'props' }
return (
<div class="RenderableComponent">
<Falsy />
Expand Down Expand Up @@ -56,16 +57,17 @@ class RenderableComponent extends Nullstack {
</head>
{!!params.condition && <div class="condition"> conditionally rendered div </div>}
<a params={{ shortList: true }} class="short-list">
{' '}
long list{' '}
long list
</a>
<a params={{ condition: true }} class="true-condition">
{' '}
long list{' '}
long list
</a>
<div data-condition={!!params.condition} />
<div data-short-list={!!params.shortList} />
<div data-name={this.name} />
<button {...props} onclick={() => {}}>
props
</button>
</div>
)
}
Expand Down
5 changes: 5 additions & 0 deletions tests/src/RenderableComponent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ describe('RenderableComponent ?condition=true', () => {
const element = await page.$('div.element')
expect(element).toBeTruthy()
})

test('elements can spread props and have named attributes', async () => {
const element = await page.$('[disabled][aria-label="props"]')
expect(element).toBeTruthy()
})
})

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