Fix for test cases mentioned in #1379 (#1401)

* Fix known issues

* Run format

* Fix linting errors

* Add comment in code for source of match logic

* Add changeset
This commit is contained in:
Daniel Engelke
2024-04-18 16:50:20 +08:00
committed by GitHub
parent 123a81e12d
commit f7c6973ae9
3 changed files with 90 additions and 6 deletions

View File

@@ -78,6 +78,35 @@ describe('css parser', () => {
expect(errors[0].filename).toEqual('foo.css');
});
it('should parse selector with comma nested inside ()', () => {
const result = parse(
'[_nghost-ng-c4172599085]:not(.fit-content).aim-select:hover:not(:disabled, [_nghost-ng-c4172599085]:not(.fit-content).aim-select--disabled, [_nghost-ng-c4172599085]:not(.fit-content).aim-select--invalid, [_nghost-ng-c4172599085]:not(.fit-content).aim-select--active) { border-color: rgb(84, 84, 84); }',
);
expect(result.parent).toEqual(null);
const rules = result.stylesheet!.rules;
expect(rules.length).toEqual(1);
let rule = rules[0] as Rule;
expect(rule.parent).toEqual(result);
expect(rule.selectors?.length).toEqual(1);
let decl = rule.declarations![0];
expect(decl.parent).toEqual(rule);
});
it('parses { and } in attribute selectors correctly', () => {
const result = parse('foo[someAttr~="{someId}"] { color: red; }');
const rules = result.stylesheet!.rules;
expect(rules.length).toEqual(1);
const rule = rules[0] as Rule;
expect(rule.selectors![0]).toEqual('foo[someAttr~="{someId}"]');
});
it('should set parent property', () => {
const result = parse(
'thing { test: value; }\n' +