Skip to content

Commit c508a02

Browse files
committed
add support for [ngClass] attribute (#187)
1 parent 8913845 commit c508a02

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/tailwindcss-language-service/src/completionProvider.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ function provideClassAttributeCompletions(
158158
end: position,
159159
})
160160

161-
const match = findLast(/(?:\s|:)class(?:Name)?=['"`{]/gi, str)
161+
const match = findLast(/(?:\s|:)(?:class(?:Name)?|\[ngClass\])=['"`{]/gi, str)
162162

163163
if (match === null) {
164164
return null
165165
}
166166

167167
const lexer =
168-
match[0][0] === ':'
168+
match[0][0] === ':' || match[0].trim().startsWith('[ngClass]')
169169
? getComputedClassAttributeLexer()
170170
: getClassAttributeLexer()
171171
lexer.reset(str.substr(match.index + match[0].length - 1))

packages/tailwindcss-language-service/src/util/find.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ export function findClassListsInHtmlRange(
135135
range?: Range
136136
): DocumentClassList[] {
137137
const text = doc.getText(range)
138-
const matches = findAll(/(?:\s|:)class(?:Name)?=['"`{]/g, text)
138+
const matches = findAll(/(?:\s|:)(?:class(?:Name)?|\[ngClass\])=['"`{]/g, text)
139139
const result: DocumentClassList[] = []
140140

141141
matches.forEach((match) => {
142142
const subtext = text.substr(match.index + match[0].length - 1)
143143

144144
let lexer =
145-
match[0][0] === ':'
145+
match[0][0] === ':' || match[0].trim().startsWith('[ngClass]')
146146
? getComputedClassAttributeLexer()
147147
: getClassAttributeLexer()
148148
lexer.reset(subtext)

0 commit comments

Comments
 (0)