Skip to content

Commit

Permalink
Better examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
thesoftwarephilosopher committed Aug 30, 2024
1 parent fc92b76 commit 44437b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion site/unity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The future of JSX</title>
<title>Proposal for standardized JSX</title>
<script type="module" src="client.js"></script>
<link rel="stylesheet" href="style.css">
</head>
Expand Down
6 changes: 3 additions & 3 deletions site/unity/samplecode.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// live playground

const b1 = <a href='/foo'>Click me</a>;
const b1 = <a {...attrs} href='/foo'>Click me</a>;

const b2 = <Button>Click me</Button>;
const b2 = <Button w={3} h={4}>Click me</Button>;

const b3 = <div class='foo' style='color:red' />;

function Button(attrs, children) {
return <>{children}</>;
return <>Button title: {...children}.</>;
}
2 changes: 1 addition & 1 deletion site/unity/vanillajsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const babelPluginVanillaJSX: babel.PluginItem = {
else if (attr.value.type === 'StringLiteral') val = t.stringLiteral(attr.value.value);
else if (attr.value.type === 'JSXElement') val = attr.value;
else if (attr.value.type === 'JSXFragment') val = attr.value;
else if (attr.value.expression.type === 'JSXEmptyExpression') throw new Error();
else if (attr.value.expression.type === 'JSXEmptyExpression') throw new Error('impossible?');
else val = attr.value.expression;

return t.objectProperty(name, val);
Expand Down

0 comments on commit 44437b7

Please sign in to comment.