diff --git a/.changeset/brave-mayflies-share.md b/.changeset/brave-mayflies-share.md deleted file mode 100644 index d755fb778ce4..000000000000 --- a/.changeset/brave-mayflies-share.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue where creating manually the i18n middleware could break the logic of the functions of the virtual module `astro:i18n` diff --git a/.changeset/curvy-elephants-fry.md b/.changeset/curvy-elephants-fry.md deleted file mode 100644 index 41bbd9e4c3eb..000000000000 --- a/.changeset/curvy-elephants-fry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue where Astro didn't throw an error when `Astro.rewrite` was used without providing the experimental flag diff --git a/.changeset/curvy-kids-call.md b/.changeset/curvy-kids-call.md deleted file mode 100644 index 72dfbb9ee1ea..000000000000 --- a/.changeset/curvy-kids-call.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue where the rewrites didn't update the status code when using manual i18n routing. diff --git a/.changeset/fair-wolves-move.md b/.changeset/fair-wolves-move.md deleted file mode 100644 index 8e64bbf9634d..000000000000 --- a/.changeset/fair-wolves-move.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Adjusts the color of punctuations in error overlay. diff --git a/.changeset/small-ties-sort.md b/.changeset/small-ties-sort.md deleted file mode 100644 index 2269d714d28a..000000000000 --- a/.changeset/small-ties-sort.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes attribute rendering for non-boolean attributes with boolean values diff --git a/examples/basics/package.json b/examples/basics/package.json index b3fe9f0a0e82..ed7f452c2051 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index de50f5c2cf65..29d33e4f9c4a 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^3.1.2", "@astrojs/rss": "^4.0.7", "@astrojs/sitemap": "^3.1.6", - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/component/package.json b/examples/component/package.json index 978663b9a210..dadb92b7b359 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.11.3" + "astro": "^4.11.5" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 98808db7a4e7..4fa718428ffe 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.11.3", + "astro": "^4.11.5", "@astrojs/react": "^3.6.0", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 21b5072bdafd..60d3bd55984d 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.1", - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 129de636ba6a..701d46f235df 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.3.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.11.3", + "astro": "^4.11.5", "lit": "^3.1.4" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 55c6b8e5fa3d..ef70525d9c6a 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.11.3", + "astro": "^4.11.5", "preact": "^10.22.1", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 7c87bdf62802..b1b672385bd5 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.0", "@preact/signals": "^1.2.3", - "astro": "^4.11.3", + "astro": "^4.11.5", "preact": "^10.22.1" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 67db6e6366a1..20484e8dd198 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "astro": "^4.11.3", + "astro": "^4.11.5", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 1b6b827e4f1a..945aa9987359 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.0", - "astro": "^4.11.3", + "astro": "^4.11.5", "solid-js": "^1.8.18" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index d10d741645a2..60658a81a378 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.6.0", - "astro": "^4.11.3", + "astro": "^4.11.5", "svelte": "^4.2.18" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 1a24194b37b5..2225addab524 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.0", - "astro": "^4.11.3", + "astro": "^4.11.5", "vue": "^3.4.31" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 5ecfb6c4d48f..fa6298bc5356 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.2", - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index fc68f9f59ae6..cf3d457f731f 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.11.3" + "astro": "^4.11.5" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index 784a92647f19..4daf9ed748f5 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.2", - "astro": "^4.11.3", + "astro": "^4.11.5", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 76cdfa03afbf..c4290981616d 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index ea5d4786dad2..988bec080883 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 24a29eda9498..93454dcae621 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 376303f2c8ee..c59ebd382edd 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.2", "@astrojs/svelte": "^5.6.0", - "astro": "^4.11.3", + "astro": "^4.11.5", "svelte": "^4.2.18" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index bc3524edb6c9..ec3a948803ce 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.11.3", + "astro": "^4.11.5", "sass": "^1.77.6", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index fa10bd67fba7..bb93e381a785 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 268fd4f9dcd8..c0847ef49ae3 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.0", "@astrojs/node": "^8.3.2", - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 060e59fe89ad..cf908daad7dd 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.1", - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index 8b55a2d9fcb1..dc53eb70d0ef 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^5.1.1", - "astro": "^4.11.3", + "astro": "^4.11.5", "hast-util-select": "^6.0.2", "rehype-autolink-headings": "^7.1.0", "rehype-slug": "^6.0.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index c35f5d90454f..2c681672dec8 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.11.3" + "astro": "^4.11.5" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 7a48c83364e1..d3a50340be37 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.2", "@astrojs/preact": "^3.5.0", - "astro": "^4.11.3", + "astro": "^4.11.5", "preact": "^10.22.1" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 9f450e18751b..c5d22c730680 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.0", "@nanostores/preact": "^0.5.1", - "astro": "^4.11.3", + "astro": "^4.11.5", "nanostores": "^0.10.3", "preact": "^10.22.1" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 4310a3351c26..8d35a24a1737 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.2", "@astrojs/tailwind": "^5.1.0", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.11.3", + "astro": "^4.11.5", "autoprefixer": "^10.4.19", "canvas-confetti": "^1.9.3", "postcss": "^8.4.39", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 9e687e22c4c5..91bb845784b8 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.11.3", + "astro": "^4.11.5", "vitest": "^1.6.0" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index db06c91c3593..935f0bcf39af 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,25 @@ # astro +## 4.11.5 + +### Patch Changes + +- [#11408](https://github.com/withastro/astro/pull/11408) [`b9e906f`](https://github.com/withastro/astro/commit/b9e906f8e75444739aa259b62489d9f5749260b9) Thanks [@matthewp](https://github.com/matthewp)! - Revert change to how boolean attributes work + +## 4.11.4 + +### Patch Changes + +- [#11362](https://github.com/withastro/astro/pull/11362) [`93993b7`](https://github.com/withastro/astro/commit/93993b77cf4915b4c0d245df9ecbf2265f5893e7) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where creating manually the i18n middleware could break the logic of the functions of the virtual module `astro:i18n` + +- [#11349](https://github.com/withastro/astro/pull/11349) [`98d9ce4`](https://github.com/withastro/astro/commit/98d9ce41f20c8bf024c937e8bde80d3c3dbbed99) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where Astro didn't throw an error when `Astro.rewrite` was used without providing the experimental flag + +- [#11352](https://github.com/withastro/astro/pull/11352) [`a55ee02`](https://github.com/withastro/astro/commit/a55ee0268e1ca22597e9b5e6d1f24b4f28ad978b) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where the rewrites didn't update the status code when using manual i18n routing. + +- [#11388](https://github.com/withastro/astro/pull/11388) [`3a223b4`](https://github.com/withastro/astro/commit/3a223b4811708cc93ebb27706118c1723e1fc013) Thanks [@mingjunlu](https://github.com/mingjunlu)! - Adjusts the color of punctuations in error overlay. + +- [#11369](https://github.com/withastro/astro/pull/11369) [`e6de11f`](https://github.com/withastro/astro/commit/e6de11f4a941e29123da3714e5b8f17d25744f0f) Thanks [@bluwy](https://github.com/bluwy)! - Fixes attribute rendering for non-boolean attributes with boolean values + ## 4.11.3 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 8bfde658e7de..df095373b316 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.11.3", + "version": "4.11.5", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/astro/src/runtime/server/render/util.ts b/packages/astro/src/runtime/server/render/util.ts index 31a78a92eea1..469491de4edf 100644 --- a/packages/astro/src/runtime/server/render/util.ts +++ b/packages/astro/src/runtime/server/render/util.ts @@ -8,6 +8,9 @@ export const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i; const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|hidden|loop|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|itemscope)$/i; +const htmlEnumAttributes = /^(?:contenteditable|draggable|spellcheck|value)$/i; +// Note: SVG is case-sensitive! +const svgEnumAttributes = /^(?:autoReverse|externalResourcesRequired|focusable|preserveAlpha)$/i; const AMPERSAND_REGEX = /&/g; const DOUBLE_QUOTE_REGEX = /"/g; @@ -64,6 +67,13 @@ export function addAttribute(value: any, key: string, shouldEscape = true) { return ''; } + if (value === false) { + if (htmlEnumAttributes.test(key) || svgEnumAttributes.test(key)) { + return markHTMLString(` ${key}="false"`); + } + return ''; + } + // compiler directives cannot be applied dynamically, log a warning and ignore. if (STATIC_DIRECTIVES.has(key)) { // eslint-disable-next-line no-console @@ -105,16 +115,11 @@ Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the } // Boolean values only need the key - if (htmlBooleanAttributes.test(key)) { - return markHTMLString(value ? ` ${key}` : ''); - } - - // Other attributes with an empty string value can omit rendering the value - if (value === '') { + if (value === true && (key.startsWith('data-') || htmlBooleanAttributes.test(key))) { return markHTMLString(` ${key}`); + } else { + return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`); } - - return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`); } // Adds support for ` diff --git a/packages/astro/test/astro-attrs.test.js b/packages/astro/test/astro-attrs.test.js index 58d1ddbbb5f0..f4a0140427a5 100644 --- a/packages/astro/test/astro-attrs.test.js +++ b/packages/astro/test/astro-attrs.test.js @@ -16,41 +16,21 @@ describe('Attributes', async () => { const $ = cheerio.load(html); const attrs = { - 'boolean-attr-true': { attribute: 'allowfullscreen', value: '' }, - 'boolean-attr-false': { attribute: 'allowfullscreen', value: undefined }, - 'boolean-attr-string-truthy': { attribute: 'allowfullscreen', value: '' }, - 'boolean-attr-string-falsy': { attribute: 'allowfullscreen', value: undefined }, - 'boolean-attr-number-truthy': { attribute: 'allowfullscreen', value: '' }, - 'boolean-attr-number-falsy': { attribute: 'allowfullscreen', value: undefined }, - 'data-attr-true': { attribute: 'data-foobar', value: 'true' }, - 'data-attr-false': { attribute: 'data-foobar', value: 'false' }, - 'data-attr-string-truthy': { attribute: 'data-foobar', value: 'foo' }, - 'data-attr-string-falsy': { attribute: 'data-foobar', value: '' }, - 'data-attr-number-truthy': { attribute: 'data-foobar', value: '1' }, - 'data-attr-number-falsy': { attribute: 'data-foobar', value: '0' }, - 'normal-attr-true': { attribute: 'foobar', value: 'true' }, - 'normal-attr-false': { attribute: 'foobar', value: 'false' }, - 'normal-attr-string-truthy': { attribute: 'foobar', value: 'foo' }, - 'normal-attr-string-falsy': { attribute: 'foobar', value: '' }, - 'normal-attr-number-truthy': { attribute: 'foobar', value: '1' }, - 'normal-attr-number-falsy': { attribute: 'foobar', value: '0' }, + 'false-str': { attribute: 'attr', value: 'false' }, + 'true-str': { attribute: 'attr', value: 'true' }, + false: { attribute: 'attr', value: undefined }, + true: { attribute: 'attr', value: 'true' }, + empty: { attribute: 'attr', value: '' }, null: { attribute: 'attr', value: undefined }, undefined: { attribute: 'attr', value: undefined }, + 'html-boolean': { attribute: 'async', value: 'async' }, + 'html-boolean-true': { attribute: 'async', value: 'async' }, + 'html-boolean-false': { attribute: 'async', value: undefined }, 'html-enum': { attribute: 'draggable', value: 'true' }, 'html-enum-true': { attribute: 'draggable', value: 'true' }, 'html-enum-false': { attribute: 'draggable', value: 'false' }, }; - assert.ok(!/allowfullscreen=/.test(html), 'boolean attributes should not have values'); - assert.ok( - !/id="data-attr-string-falsy"\s+data-foobar=/.test(html), - "data attributes should not have values if it's an empty string" - ); - assert.ok( - !/id="normal-attr-string-falsy"\s+data-foobar=/.test(html), - "normal attributes should not have values if it's an empty string" - ); - // cheerio will unescape the values, so checking that the url rendered unescaped to begin with has to be done manually assert.equal( html.includes('https://example.com/api/og?title=hello&description=somedescription'), @@ -66,7 +46,7 @@ describe('Attributes', async () => { for (const id of Object.keys(attrs)) { const { attribute, value } = attrs[id]; const attr = $(`#${id}`).attr(attribute); - assert.equal(attr, value, `Expected ${attribute} to be ${value} for #${id}`); + assert.equal(attr, value); } }); diff --git a/packages/astro/test/fixtures/astro-attrs/src/pages/index.astro b/packages/astro/test/fixtures/astro-attrs/src/pages/index.astro index 8f2576650f62..7ac96635fd14 100644 --- a/packages/astro/test/fixtures/astro-attrs/src/pages/index.astro +++ b/packages/astro/test/fixtures/astro-attrs/src/pages/index.astro @@ -1,30 +1,19 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + - /tmp/hello.txt"} /> - + + + +