Skip to content

Commit 69a2e0b

Browse files
committed
fixup! fix: do not wrongly suggest that a lang attribute is missing when finding comments
1 parent f400e90 commit 69a2e0b

File tree

1 file changed

+2
-2
lines changed
  • packages/vite-plugin-svelte/src/utils

1 file changed

+2
-2
lines changed

packages/vite-plugin-svelte/src/utils/error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ export function enhanceCompileError(err, originalCode, preprocessors) {
128128
if (couldBeFixedByCssPreprocessor(err.code)) {
129129
// Reference from Svelte: https://github.com/sveltejs/svelte/blob/9926347ad9dbdd0f3324d5538e25dcb7f5e442f8/packages/svelte/src/compiler/preprocess/index.js#L257
130130
const styleRe =
131-
/<style((?:\s+[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g;
131+
/<!--[^]*?-->|<style((?:\s+[^=>'"/]+=(?:"[^"]*"|'[^']*'|[^>\s]+)|\s+[^=>'"/]+)*\s*)(?:\/>|>([\S\s]*?)<\/style>)/g;
132132

133133
let m;
134134
while ((m = styleRe.exec(originalCode))) {
135135
// Warn missing lang attribute
136-
if (!m[1]?.includes('lang=')) {
136+
if (!m[0]?.startsWith('<!--') && !m[1]?.includes('lang=')) {
137137
additionalMessages.push('Did you forget to add a lang attribute to your style tag?');
138138
}
139139
// Warn missing style preprocessor

0 commit comments

Comments
 (0)