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

View File

@ -135,14 +135,14 @@ export function findClassListsInHtmlRange(
range?: Range range?: Range
): DocumentClassList[] { ): DocumentClassList[] {
const text = doc.getText(range) 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[] = [] const result: DocumentClassList[] = []
matches.forEach((match) => { matches.forEach((match) => {
const subtext = text.substr(match.index + match[0].length - 1) const subtext = text.substr(match.index + match[0].length - 1)
let lexer = let lexer =
match[0][0] === ':' match[0][0] === ':' || match[0].trim().startsWith('[ngClass]')
? getComputedClassAttributeLexer() ? getComputedClassAttributeLexer()
: getClassAttributeLexer() : getClassAttributeLexer()
lexer.reset(subtext) lexer.reset(subtext)