Which JavaScript-framework can search CSS stylesheet rules and edit their properties?

后端 未结 4 1158
野趣味
野趣味 2021-02-01 23:22

The Question

Which JavaScript framework (prototype, script.aculo.us, Mootools, MochiKit...) has decent CSS rule editing support?

This is abou

4条回答
  •  庸人自扰
    2021-02-01 23:41

    None, but please prove me wrong...

    A decent implementation would have to discuss/document the following first:

    • how it walks the CSS tree (including @imports and @media)
    • how the walk can be configured (which @media and which sheets are considered)
    • how cross domain access restrictions are handled/circumvented
    • as CSS has no IDs for the rules itself: only the selector can act as a decent rule identifiers
      • as IE8 and below split up multi-selectors, how smart is the framework to handle this?
      • IE9 is worse (see quirksmode.org)
    • as multiple rules could be selected by one selector, how are they ordered?
    • how can the rule in charge be found from a rule-set knowing the property we want to edit?

    Until the frameworks catch up, consider:

    • get the style/link node where the rule you look for is in
    • use the node.sheet to go to the CSSStyleSheet directly
    • check quirksmode.org for quirks and f... IE
    • loop over the rules to find your rule(s) via known selector
    • DOM CSSStyleRule gives you all the power you need over any style rule

提交回复
热议问题