Skip to content

Commit 5da79d5

Browse files
committed
allow unknown css pseudo classes and attribute selectors #43
1 parent 87dafd5 commit 5da79d5

File tree

17 files changed

+1320
-416
lines changed

17 files changed

+1320
-416
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
- [x] attribute selector
1414
- [x] combinator
1515
- [x] simple selector
16-
- [ ] nested selector
16+
- [x] nested selector
17+
- [ ] strict mode: allow unknown items such as pseudo classes
18+
- [x] allow unknown pseudo classes
19+
- [x] allow unknown attribute selectors
1720
- [ ] strip universal selector when possible
1821

1922
# v0.6.0

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ Include ParseOptions and RenderOptions
146146
- inlineCssVariables: boolean, optional. replace some css variables with their actual value. they must be declared once in the :root {} or html {} rule.
147147
- removeEmpty: boolean, optional. remove empty rule lists from the ast.
148148

149+
> Minify Options
150+
151+
- validation: boolean, optional. enable strict css validation using (mdn data)[https://github.com/mdn/data]. only the selector is validated at this time.
152+
149153
> Sourcemap Options
150154
151155
- src: string, optional. original css file location to be used with sourcemap, also used to resolve url().
@@ -317,6 +321,104 @@ table.colortable {
317321
}
318322
```
319323

324+
### CSS Validation
325+
326+
CSS
327+
328+
```css
329+
330+
#404 {
331+
--animate-duration: 1s;
332+
}
333+
334+
.s, #404 {
335+
--animate-duration: 1s;
336+
}
337+
338+
.s [type="text" {
339+
--animate-duration: 1s;
340+
}
341+
342+
.s [type="text"]] {
343+
--animate-duration: 1s;
344+
}
345+
346+
.s [type="text"] {
347+
--animate-duration: 1s;
348+
}
349+
350+
.s [type="text" i] {
351+
--animate-duration: 1s;
352+
}
353+
354+
.s [type="text" s] {
355+
--animate-duration: 1s;
356+
}
357+
358+
.s [type="text" b] {
359+
--animate-duration: 1s;
360+
}
361+
362+
.s [type="text" b], {
363+
--animate-duration: 1s;
364+
}
365+
366+
.s [type="text" b]+ {
367+
--animate-duration: 1s;
368+
}
369+
370+
.s [type="text" b]+ b {
371+
--animate-duration: 1s;
372+
}
373+
374+
.s [type="text" i]+ b {
375+
--animate-duration: 1s;
376+
}
377+
378+
379+
.s [type="text"())] {
380+
--animate-duration: 1s;
381+
}
382+
.s() {
383+
--animate-duration: 1s;
384+
}
385+
.s:focus {
386+
--animate-duration: 1s;
387+
}
388+
```
389+
390+
with validation enabled
391+
392+
```javascript
393+
import {parse, render} from '@tbela99/css-parser';
394+
const options = {minify: true, validate: true};
395+
const {code} = await parse(css, options).then(result => render(result.ast, {minify: false}));
396+
//
397+
console.debug(code);
398+
```
399+
400+
```css
401+
.s:is([type=text],[type=text i],[type=text s],[type=text i]+b,:focus) {
402+
--animate-duration: 1s
403+
}
404+
```
405+
406+
with validation disabled
407+
408+
```javascript
409+
import {parse, render} from '@tbela99/css-parser';
410+
const options = {minify: true, validate: false};
411+
const {code} = await parse(css, options).then(result => render(result.ast, {minify: false}));
412+
//
413+
console.debug(code);
414+
```
415+
416+
```css
417+
.s:is([type=text],[type=text i],[type=text s],[type=text b],[type=text b]+b,[type=text i]+b,:focus) {
418+
--animate-duration: 1s
419+
}
420+
```
421+
320422
### Nested CSS Expansion
321423

322424
CSS

0 commit comments

Comments
 (0)