Handlebars: Stop formatting <style lang=""> as CSS (#20031)

Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
Konv Suuandfisker authored and GitHub committed 2026-09-11 16:09:34 +08:00
1 parent 691525df47
commit 7ed24db8e2
6 files changed
+89 -53

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
#### Don't format `<style lang="">` as CSS (#20031 by @kovsu)
<!-- prettier-ignore -->
```hbs
{{! Input }}
<style lang="">
.a { color: red;
}
</style>
{{! Prettier stable }}
<style lang="">
.a {
color: red;
}
</style>
{{! Prettier main }}
<style lang="">
.a { color: red;
}
</style>
```
+1 -2
View File
@@ -23,8 +23,7 @@ function embed(path /* , options*/) {
languageAttribute &&
!(
languageAttribute.value.type === "TextNode" &&
(languageAttribute.value.chars === "" ||
languageAttribute.value.chars === "css")
languageAttribute.value.chars === "css"
)
) {
return;
@@ -134,26 +134,21 @@ parsers: ["glimmer"]
</style>
</div>
=====================================output=====================================
<div>
<style lang="css">
.a {
color: red;
}
</style>
</div>
================================================================================
`;
exports[`with-lang-attribute-2.hbs format 1`] = `
====================================options=====================================
parsers: ["glimmer"]
printWidth: 80 (default) |
=====================================input======================================
<div>
<style lang>
.a { color: red;
}
</style>
</div>
<div>
<style lang="">
.a {color: red;
}
@@ -161,22 +156,6 @@ parsers: ["glimmer"]
</style>
</div>
=====================================output=====================================
<div>
<style lang>
.a {
color: red;
}
</style>
</div>
================================================================================
`;
exports[`with-lang-attribute-3.hbs format 1`] = `
====================================options=====================================
parsers: ["glimmer"]
printWidth: 80 (default) |
=====================================input======================================
<style lang="unknown">
@@ -188,6 +167,28 @@ parsers: ["glimmer"]
</style>
=====================================output=====================================
<div>
<style lang="css">
.a {
color: red;
}
</style>
</div>
<div>
<style lang>
.a { color: red;
}
</style>
</div>
<div>
<style lang="">
.a {color: red;
}
</style>
</div>
<style lang="unknown">
.a {color: red;
}
@@ -1,10 +0,0 @@
<div>
<style lang>
.a {color: red;
}
</style>
</div>
@@ -1,9 +0,0 @@
<style lang="unknown">
.a {color: red;
}
</style>
@@ -8,3 +8,35 @@
</style>
</div>
<div>
<style lang>
.a { color: red;
}
</style>
</div>
<div>
<style lang="">
.a {color: red;
}
</style>
</div>
<style lang="unknown">
.a {color: red;
}
</style>