Skip to content

Commit b89dbee

Browse files
authored
fix(language-plugin-pug): ignore duplicate attribute error of class (#5100)
1 parent 95c26c3 commit b89dbee

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/language-plugin-pug/index.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { SourceMap } from '@volar/source-map';
2-
import type { VueLanguagePlugin } from '@vue/language-core';
2+
import type { CompilerDOM, VueLanguagePlugin } from '@vue/language-core';
33
import * as pug from 'volar-service-pug/lib/languageService';
44

5+
const classRegex = /^class\s*=/;
6+
57
const plugin: VueLanguagePlugin = ({ modules }) => {
68

79
return {
@@ -71,6 +73,13 @@ const plugin: VueLanguagePlugin = ({ modules }) => {
7173
options?.onWarn?.(createProxyObject(warning));
7274
},
7375
onError(error) {
76+
// #5099
77+
if (
78+
error.code === 2 satisfies CompilerDOM.ErrorCodes.DUPLICATE_ATTRIBUTE
79+
&& classRegex.test(pugFile.htmlCode.slice(error.loc?.start.offset))
80+
) {
81+
return;
82+
}
7483
options?.onError?.(createProxyObject(error));
7584
},
7685
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<template lang="pug">
2+
div(
3+
class="foo"
4+
class="bar"
5+
)
6+
</template>

0 commit comments

Comments
 (0)