Skip to content

Commit 0bddba4

Browse files
authored
fix: Properly handled unquoted attributes with numbers and dashes (#35)
1 parent 0726e00 commit 0bddba4

5 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@astrojs/compiler-binding": patch
3+
"@astrojs/compiler-rs": patch
4+
---
5+
6+
Fixes `Unexpected token` error when an HTML attribute has an unquoted value such as a number (`<input maxlength=255>`) or contains characters like `-` or `#`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div data-id=hello-world data-color=#abc123>x</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
source: crates/astro_codegen/tests/snapshots.rs
3+
input_file: crates/astro_codegen/tests/fixtures/_33_unquoted_dashed_attribute.astro
4+
---
5+
import { render as $$render, createComponent as $$createComponent, maybeRenderHead as $$maybeRenderHead, createMetadata as $$createMetadata } from "http://localhost:3000/";
6+
export const $$metadata = $$createMetadata(import.meta.url, {
7+
modules: [],
8+
hydratedComponents: [],
9+
clientOnlyComponents: [],
10+
hydrationDirectives: new Set([]),
11+
hoisted: []
12+
});
13+
const $$Component = $$createComponent(($$result, $$props, $$slots) => {
14+
return $$render`${$$maybeRenderHead($$result)}<div data-id="hello-world" data-color="#abc123">x</div>`;
15+
}, undefined, undefined);
16+
export default $$Component;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<input type="text" minlength=4 maxlength=255 />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
source: crates/astro_codegen/tests/snapshots.rs
3+
input_file: crates/astro_codegen/tests/fixtures/_33_unquoted_numeric_attribute.astro
4+
---
5+
import { render as $$render, createComponent as $$createComponent, maybeRenderHead as $$maybeRenderHead, createMetadata as $$createMetadata } from "http://localhost:3000/";
6+
export const $$metadata = $$createMetadata(import.meta.url, {
7+
modules: [],
8+
hydratedComponents: [],
9+
clientOnlyComponents: [],
10+
hydrationDirectives: new Set([]),
11+
hoisted: []
12+
});
13+
const $$Component = $$createComponent(($$result, $$props, $$slots) => {
14+
return $$render`${$$maybeRenderHead($$result)}<input type="text" minlength="4" maxlength="255">`;
15+
}, undefined, undefined);
16+
export default $$Component;

0 commit comments

Comments
 (0)