fix: Fix CSS rules captured in Safari (#1253)

* fix: Fix CSS rules captured in Safari

* Apply formatting changes

* add changeset

* fix

---------

Co-authored-by: mydea <mydea@users.noreply.github.com>
This commit is contained in:
Francesco Novy
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 5c3e1cf1e7
commit 3cf1b8b450
4 changed files with 34 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import { parse, Rule, Media } from '../src/css';
import { validateStringifiedCssRule } from './../src/utils';
describe('css parser', () => {
it('should save the filename and source', () => {
@@ -106,4 +107,17 @@ describe('css parser', () => {
decl = rule.declarations![0];
expect(decl.parent).toEqual(rule);
});
it('parses : in attribute selectors correctly', () => {
const out1 = validateStringifiedCssRule('[data-foo] { color: red; }');
expect(out1).toEqual('[data-foo] { color: red; }');
const out2 = validateStringifiedCssRule('[data-foo:other] { color: red; }');
expect(out2).toEqual('[data-foo\\:other] { color: red; }');
const out3 = validateStringifiedCssRule(
'[data-aa\\:other] { color: red; }',
);
expect(out3).toEqual('[data-aa\\:other] { color: red; }');
});
});