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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Nullstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Get to know the [Nullstack Contributors](https://nullstack.app/contributors)

## License

Nullstack is released under the [MIT License](https://opensource.org/licenses/MIT).
Nullstack is released under the [MIT License](LICENSE).
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