diff --git a/packages/abbreviation/src/parser/index.ts b/packages/abbreviation/src/parser/index.ts index d88fe27c..f32aa346 100644 --- a/packages/abbreviation/src/parser/index.ts +++ b/packages/abbreviation/src/parser/index.ts @@ -181,6 +181,8 @@ function shortAttribute(scanner: TokenScanner, type: 'class' | 'id', options: Pa if (options.jsx && text(scanner)) { attr.value = getText(scanner); attr.expression = true; + } else if (quoted(scanner)) { + attr.value = slice(scanner, scanner.start + 1, scanner.pos - 1) as ValueToken[]; } else { attr.value = literal(scanner) ? slice(scanner) as ValueToken[] : void 0; } diff --git a/packages/abbreviation/test/parser.ts b/packages/abbreviation/test/parser.ts index 2a54f3fc..2acc181b 100644 --- a/packages/abbreviation/test/parser.ts +++ b/packages/abbreviation/test/parser.ts @@ -105,9 +105,14 @@ describe('Parser', () => { // Elements with attributes equal(str('div[foo=bar]'), '
'); equal(str('div.a[b=c]'), ''); + equal(str('div.mr-\\[500\\][a=b]'), ''); equal(str('div[b=c].a'), ''); equal(str('div[a=b][c="d"]'), ''); equal(str('[b=c]'), ' b=c>?>'); + equal(str('.a\\[b-c\\]'), ' class=a[b-c]>?>'); + equal(str('."a:[b-c]"'), ' class=a:[b-c]>?>'); + equal(str('."peer-[.is-dirty]:peer-required:block"'), ' class=peer-[.is-dirty]:peer-required:block>?>'); + equal(str('."mr-50"."peer-[:nth-of-type(3)_&]:block"'), ' class=mr-50 class=peer-[:nth-of-type(3)_&]:block>?>'); equal(str('.a[b=c]'), ' class=a b=c>?>'); equal(str('[b=c].a#d'), ' b=c class=a id=d>?>'); equal(str('[b=c]a'), ' b=c>?>', 'Do not consume node name after attribute set');