jotform / css.js

A lightweight, battle tested, fast, CSS parser in JavaScript
https://medium.com/jotform-form-builder/writing-a-css-parser-in-javascript-3ecaa1719a43
MIT License
426 stars 63 forks source link

For client side, any reason why not use CSSOM? #17

Open andreinitescu opened 8 years ago

andreinitescu commented 8 years ago

For client side, any specific reason not to just use CSSOM? http://jsfiddle.net/v2JsZ/

kemaldaggen commented 8 years ago

Hey @andreinitescu, thanks for the input. We thought about it too. But finally decided with a custom CSS parser. Besides the obvious server side css parsing benefits, here are our reasons for not to use CSSOM:

But you are right, if we have programmatic direct access to browser's internal css parser, that would be way better.

andreinitescu commented 8 years ago

Thank you Kemal. I'm mostly worried about first one, compatibility across browsers. Do you have any more info regarding that, any quick example which comes to your mind?

In order to parse CSS by CSSOM using a <style> element , I see the CSSOM objects and properties required are LinkStyle.sheet, CSSStyleSheet.cssRules, CSSStyleRule.style, CSSStyleDeclaration, which all seem from DOM Level 2 specification. But maybe I'm missing something.