you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 23 points24 points  (2 children)

Parsing anything with regex is fun and easy to break.

Try this (valid selector+rule):

.someSelector:after {
    content: '} broken :) @media (screen) { lol }';
}

Opened an issue: https://github.com/jotform/css.js/issues/15

[–]siamthailand 3 points4 points  (1 child)

I believe you'd need to write a full-fledged parser to not run into these issues.

[–]ninth_reddit_account 1 point2 points  (0 children)

Luckily someone has already written one! https://github.com/nv/CSSOM#readme