Skip to content

Commit

Permalink
Allow data-astro-reload to take a value (#1012)
Browse files Browse the repository at this point in the history
* Allow data-astro-reload to take a value

* Add a changeset

* Update .changeset/light-ligers-rhyme.md

---------

Co-authored-by: Emanuele Stoppa <[email protected]>
  • Loading branch information
matthewp and ematipico authored Jun 24, 2024
1 parent ead5809 commit 0bb2746
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-ligers-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/compiler": patch
---

Allow `data-astro-reload` to take a value
9 changes: 0 additions & 9 deletions internal/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ func WarnAboutMisplacedReload(n *astro.Node, h *handler.Handler) {
/*
* When set on <a>, <form> or <area>,
* the data-astro-reload attribute replaces view transitions between pages with a full page loads.
* The data-astro-reload attribute is not supported for other elements. It does not accept a value.
*/

if n.Type != astro.ElementNode || n.Data != "a" && n.Data != "area" && n.Data != "form" {
Expand All @@ -374,14 +373,6 @@ func WarnAboutMisplacedReload(n *astro.Node, h *handler.Handler) {
Range: loc.Range{Loc: attr.KeyLoc, Len: len(attr.Key)},
})
}
if attr.Val != "" {
h.AppendWarning(&loc.ErrorWithRange{
Code: loc.WARNING_UNSUPPORTED_EXPRESSION,
Text: "The data-astro-reload attribute does not accept a value",
Range: loc.Range{Loc: attr.ValLoc, Len: len(attr.Val)},
})
return
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions packages/compiler/test/transition/data-astro.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { transform } from '@astrojs/compiler';
import { parse, transform } from '@astrojs/compiler';
import { test } from 'uvu';
import * as assert from 'uvu/assert';

Expand All @@ -14,10 +14,9 @@ const FIXTURE = `

test('Issues warnings for data-astro-* attributes', async () => {
const result = await transform(FIXTURE);
assert.equal(result.diagnostics.length, 3);
assert.equal(result.diagnostics.length, 2);
assert.equal(result.diagnostics[0].code, 2000);
assert.equal(result.diagnostics[1].code, 2005);
assert.equal(result.diagnostics[2].code, 2010);
assert.equal(result.diagnostics[1].code, 2010);
});

test.run();

0 comments on commit 0bb2746

Please sign in to comment.