diff --git a/changelog_unreleased/html/12882.md b/changelog_unreleased/html/12882.md new file mode 100644 index 000000000..3e94364b6 --- /dev/null +++ b/changelog_unreleased/html/12882.md @@ -0,0 +1,32 @@ +#### Support Speculation Rules API formatting in HTML (#12882 by @sosukesuzuki) + +Please read https://web.dev/speculative-prerendering/ for about Speculation Rules API. + + +```html + + + + + + + + + +``` diff --git a/cspell.json b/cspell.json index 7c8802db1..6e12e2740 100644 --- a/cspell.json +++ b/cspell.json @@ -304,6 +304,7 @@ "softlines", "Sorin", "Sosuke", + "speculationrules", "srcset", "Stachowiak", "standalones", diff --git a/src/language-html/utils/index.js b/src/language-html/utils/index.js index 20261d1e9..00b1e2412 100644 --- a/src/language-html/utils/index.js +++ b/src/language-html/utils/index.js @@ -364,7 +364,10 @@ function _inferScriptParser(node) { return "html"; } - if (type && (type.endsWith("json") || type.endsWith("importmap"))) { + if ( + (type && (type.endsWith("json") || type.endsWith("importmap"))) || + type === "speculationrules" + ) { return "json"; } diff --git a/tests/format/html/script/__snapshots__/jsfmt.spec.js.snap b/tests/format/html/script/__snapshots__/jsfmt.spec.js.snap index 52ec843f5..ce92e69e4 100644 --- a/tests/format/html/script/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/html/script/__snapshots__/jsfmt.spec.js.snap @@ -171,6 +171,15 @@ End Function + + + =====================================output===================================== + + ================================================================================ `; diff --git a/tests/format/html/script/script.html b/tests/format/html/script/script.html index 67b16cd88..eff326ee5 100644 --- a/tests/format/html/script/script.html +++ b/tests/format/html/script/script.html @@ -31,4 +31,12 @@ End Function \ No newline at end of file + + +