diff --git a/changelog_unreleased/vue/pr-9052.md b/changelog_unreleased/vue/pr-9052.md
new file mode 100644
index 000000000000..06cbc594b4f9
--- /dev/null
+++ b/changelog_unreleased/vue/pr-9052.md
@@ -0,0 +1,20 @@
+#### Fix format blocks with `src` attribute ([#9052](https://github.com/prettier/prettier/pull/9052) by [@fisker](https://github.com/fisker))
+
+
+```vue
+
+
+
+
+
+
+
+
+
+
+
+
+
+```
diff --git a/src/language-html/utils.js b/src/language-html/utils.js
index 6424395ec916..cd6540c7a4fd 100644
--- a/src/language-html/utils.js
+++ b/src/language-html/utils.js
@@ -428,7 +428,7 @@ function inferScriptParser(node, options) {
return (
_inferScriptParser(node) ||
inferStyleParser(node) ||
- getParserName(node.attrMap.lang, options)
+ (!("src" in node.attrMap) && getParserName(node.attrMap.lang, options))
);
}
}
diff --git a/tests/vue/with-plugins/__snapshots__/jsfmt.spec.js.snap b/tests/vue/with-plugins/__snapshots__/jsfmt.spec.js.snap
index e5ba289f5936..052853295780 100644
--- a/tests/vue/with-plugins/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/vue/with-plugins/__snapshots__/jsfmt.spec.js.snap
@@ -235,3 +235,146 @@ printWidth: 80
================================================================================
`;
+
+exports[`with-src.vue - {"embeddedLanguageFormatting":"off"} format 1`] = `
+====================================options=====================================
+embeddedLanguageFormatting: "off"
+parsers: ["vue"]
+printWidth: 80
+ | printWidth
+=====================================input======================================
+
+
+
+
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+
+
+PrEtTiEr
+
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+
+
+=====================================output=====================================
+
+
+
+
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+
+
+PrEtTiEr
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+
+
+================================================================================
+`;
+
+exports[`with-src.vue format 1`] = `
+====================================options=====================================
+parsers: ["vue"]
+printWidth: 80
+ | printWidth
+=====================================input======================================
+
+
+
+
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+
+
+PrEtTiEr
+
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+
+
+=====================================output=====================================
+
+
+
+
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+
+
+PrEtTiEr
+
+
+
+PRETTIER
+
+
+PRETTIER
+
+
+
+
+
+
+
+
+
+================================================================================
+`;
diff --git a/tests/vue/with-plugins/with-src.vue b/tests/vue/with-plugins/with-src.vue
new file mode 100644
index 000000000000..209f53b95193
--- /dev/null
+++ b/tests/vue/with-plugins/with-src.vue
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+
+
+PrEtTiEr
+
+
+
+PrEtTiEr
+PrEtTiEr
+
+
+
+
+
+
+