Skip to content

Commit 8e9ee03

Browse files
committed
fix: change the name of the generated attribute
1 parent 997a9f1 commit 8e9ee03

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

.changeset/itchy-lobsters-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/compiler': patch
3+
---
4+
5+
Change the value of the generated attribute

internal/printer/printer_css_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestPrinterCSS(t *testing.T) {
7070
<h1 class="title">Page Title</h1>
7171
<p class="body">I’m a page</p>`,
7272
scopedStyleStrategy: "attribute",
73-
want: ".title[data-astro-hash-DPOHFLYM]{font-family:fantasy;font-size:28px}.body[data-astro-hash-DPOHFLYM]{font-size:1em}",
73+
want: ".title[data-astro-cid-DPOHFLYM]{font-family:fantasy;font-size:28px}.body[data-astro-cid-DPOHFLYM]{font-size:1em}",
7474
},
7575
}
7676

internal/transform/scope-html.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func injectScopedClass(n *astro.Node, opts TransformOptions) {
168168
})
169169
} else {
170170
n.Attr = append(n.Attr, astro.Attribute{
171-
Key: fmt.Sprintf(`data-astro-hash-%s`, opts.Scope),
171+
Key: fmt.Sprintf(`data-astro-cid-%s`, opts.Scope),
172172
Type: astro.EmptyAttribute,
173173
})
174174
}

internal/transform/transform_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func transformScopingFixtures() []struct {
139139
<style>.class{}</style>
140140
<div />
141141
`,
142-
want: `<div data-astro-hash-XXXXXX></div>`,
142+
want: `<div data-astro-cid-XXXXXX></div>`,
143143
scopeStyle: "attribute",
144144
},
145145
{
@@ -148,7 +148,7 @@ func transformScopingFixtures() []struct {
148148
<style>.font{}</style>
149149
<div />
150150
`,
151-
want: `<div data-astro-hash-XXXXXX></div>`,
151+
want: `<div data-astro-cid-XXXXXX></div>`,
152152
scopeStyle: "attribute",
153153
},
154154
{
@@ -157,7 +157,7 @@ func transformScopingFixtures() []struct {
157157
<style>.font{}</style>
158158
<div />
159159
`,
160-
want: `<div data-astro-hash-XXXXXX></div>`,
160+
want: `<div data-astro-cid-XXXXXX></div>`,
161161
scopeStyle: "attribute",
162162
},
163163
{
@@ -166,7 +166,7 @@ func transformScopingFixtures() []struct {
166166
<style>.font{}</style>
167167
<div class="foo" />
168168
`,
169-
want: `<div class="foo" data-astro-hash-XXXXXX></div>`,
169+
want: `<div class="foo" data-astro-cid-XXXXXX></div>`,
170170
scopeStyle: "attribute",
171171
},
172172
}

lib/esbuild/css_printer/astro_features.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func (p *printer) printScopedSelector() bool {
1212
if p.options.ScopeStrategy == ScopeStrategyWhere {
1313
str = fmt.Sprintf(":where(.astro-%s)", p.options.Scope)
1414
} else if p.options.ScopeStrategy == ScopeStrategyAttribute {
15-
str = fmt.Sprintf("[data-astro-hash-%s]", p.options.Scope)
15+
str = fmt.Sprintf("[data-astro-cid-%s]", p.options.Scope)
1616
} else {
1717
str = fmt.Sprintf(".astro-%s", p.options.Scope)
1818
}

0 commit comments

Comments
 (0)