Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partial jsx (expressions) #43

Closed
wants to merge 2 commits into from
Closed
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
20 changes: 20 additions & 0 deletions test/fixtures/partials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default class {
renderTest() {
return <p>test</p>
}

render () {
const test = <div>{this.renderTest}</div>

return (
<div>
{test}
<style jsx>{`
p {
color: red;
}
`}</style>
</div>
)
}
}
18 changes: 18 additions & 0 deletions test/fixtures/partials.out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import _JSXStyle from "styled-jsx/style";

export default class {
renderTest() {
return <p data-jsx={"1891769468"}>test</p>
}

render () {
const test = <div data-jsx={"1891769468"}>{this.renderTest}</div>

return (
<div data-jsx={"1891769468"}>
{test}
<_JSXStyle css={"p[data-jsx=\"1891769468\"] {color: red;}"} data-jsx={"1891769468"} />
</div>
)
}
}
6 changes: 6 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ test('mixed global and scoped', async t => {
const out = await read('./fixtures/mixed-global-scoped.out.js')
t.is(code, out.trim())
})

test('works with partial jsx (expressions)', async t => {
const {code} = await transform('./fixtures/partials.js')
const out = await read('./fixtures/partials.out.js')
t.is(code, out.trim())
})