add support for [ngClass] attribute (#187)

master
Brad Cornes 2020-11-30 18:15:31 +00:00
parent 8913845616
commit c508a028d4
2 changed files with 4 additions and 4 deletions

View File

@ -158,14 +158,14 @@ function provideClassAttributeCompletions(
end: position,
})
const match = findLast(/(?:\s|:)class(?:Name)?=['"`{]/gi, str)
const match = findLast(/(?:\s|:)(?:class(?:Name)?|\[ngClass\])=['"`{]/gi, str)
if (match === null) {
return null
}
const lexer =
match[0][0] === ':'
match[0][0] === ':' || match[0].trim().startsWith('[ngClass]')
? getComputedClassAttributeLexer()
: getClassAttributeLexer()
lexer.reset(str.substr(match.index + match[0].length - 1))

View File

@ -135,14 +135,14 @@ export function findClassListsInHtmlRange(
range?: Range
): DocumentClassList[] {
const text = doc.getText(range)
const matches = findAll(/(?:\s|:)class(?:Name)?=['"`{]/g, text)
const matches = findAll(/(?:\s|:)(?:class(?:Name)?|\[ngClass\])=['"`{]/g, text)
const result: DocumentClassList[] = []
matches.forEach((match) => {
const subtext = text.substr(match.index + match[0].length - 1)
let lexer =
match[0][0] === ':'
match[0][0] === ':' || match[0].trim().startsWith('[ngClass]')
? getComputedClassAttributeLexer()
: getClassAttributeLexer()
lexer.reset(subtext)