Skip to content

Commit

Permalink
Treat slash as value literal
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed Mar 21, 2021
1 parent 0f2cf43 commit 5367980
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/css-abbreviation/src/tokenizer/index.ts
Expand Up @@ -352,7 +352,6 @@ function operatorType(ch: number): OperatorType | undefined {
return (ch === Chars.Sibling && OperatorType.Sibling)
|| (ch === Chars.Excl && OperatorType.Important)
|| (ch === Chars.Comma && OperatorType.ArgumentDelimiter)
|| (ch === Chars.Slash && OperatorType.ArgumentDelimiter)
|| (ch === Chars.Colon && OperatorType.PropertyDelimiter)
|| (ch === Chars.Dash && OperatorType.ValueDelimiter)
|| void 0;
Expand All @@ -374,7 +373,7 @@ function isBracket(code: number) {
}

function isLiteral(code: number) {
return isAlphaWord(code) || code === Chars.Percent;
return isAlphaWord(code) || code === Chars.Percent || code === Chars.Slash;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/css-abbreviation/test/parser.ts
Expand Up @@ -74,7 +74,7 @@ describe('CSS Abbreviation parser', () => {
equal(fn.name, 'scale3d');

prop = parse('repeat(2,auto) / repeat(auto-fit, minmax(250px, 1fr))', opt)[0];
equal(prop.value.length, 2);
equal(prop.value.length, 1);
});

it('errors', () => {
Expand Down
4 changes: 3 additions & 1 deletion test/stylesheet.ts
Expand Up @@ -10,7 +10,8 @@ const defaultConfig = resolveConfig({
},
snippets: {
mten: 'margin: 10px;',
fsz: 'font-size'
fsz: 'font-size',
gt: 'grid-template: repeat(2,auto) / repeat(auto-fit, minmax(250px, 1fr))'
},
cache: {},
});
Expand Down Expand Up @@ -162,6 +163,7 @@ describe('Stylesheet abbreviations', () => {
// Insert value into snippet fields
equal(expand('@k-name'), '@keyframes name {\n\t${2}\n}');
equal(expand('@k-name10'), '@keyframes name {\n\t10\n}');
equal(expand('gt'), 'grid-template: repeat(2, auto) / repeat(auto-fit, minmax(250px, 1fr));');
});

it('multiple properties', () => {
Expand Down

0 comments on commit 5367980

Please sign in to comment.