diff options
author | 2021-03-19 14:55:06 -0600 | |
---|---|---|
committer | 2021-03-19 14:55:06 -0600 | |
commit | 8ebc077cb0d9f50aae22d2651bd5ef13fe4641d3 (patch) | |
tree | e5ea0de86dcb8f4c72155430216e9fd808206dea /src/codegen/index.ts | |
parent | d75107a20e971ad26a0398229b2b3fd13c45c6ee (diff) | |
download | astro-8ebc077cb0d9f50aae22d2651bd5ef13fe4641d3.tar.gz astro-8ebc077cb0d9f50aae22d2651bd5ef13fe4641d3.tar.zst astro-8ebc077cb0d9f50aae22d2651bd5ef13fe4641d3.zip |
Inject styling in HTML AST (#9)
* Inject styling in HTML AST
* Restore optimize structure
Diffstat (limited to 'src/codegen/index.ts')
-rw-r--r-- | src/codegen/index.ts | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/codegen/index.ts b/src/codegen/index.ts index 3257d9936..9b3104f0a 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -190,7 +190,6 @@ export async function codegen(ast: Ast, { compileOptions }: CodeGenOptions): Pro let collectionItem: JsxItem | undefined; let currentItemName: string | undefined; let currentDepth = 0; - const classNames: Set<string> = new Set(); walk(ast.html, { enter(node: TemplateNode) { @@ -275,6 +274,11 @@ export async function codegen(ast: Ast, { compileOptions }: CodeGenOptions): Pro this.skip(); return; } + case 'Style': { + const attributes = getAttributes(node.attributes); + items.push({ name: 'style', jsx: `h("style", ${attributes ? generateAttributes(attributes) : 'null'}, ${JSON.stringify(node.content.styles)})` }); + break; + } case 'Text': { const text = getTextFromAttribute(node); if (mode === 'SLOT') { @@ -328,6 +332,9 @@ export async function codegen(ast: Ast, { compileOptions }: CodeGenOptions): Pro collectionItem = undefined; } return; + case 'Style': { + return; + } default: throw new Error('Unexpected node type: ' + node.type); } |