cssutils icon indicating copy to clipboard operation
cssutils copied to clipboard

@support selectors results into an UNKNOWN_RULE

Open IrfaanS786biz opened this issue 3 years ago • 3 comments

Would it be possible to support the @support selector please?

Many Thanks in advance

IrfaanS786biz avatar Apr 21 '21 20:04 IrfaanS786biz

Thanks for the request. This project doesn't have active implementers, but it will welcome contributors with open arms.

jaraco avatar May 24 '21 02:05 jaraco

@jaraco contributing @support selector is beyond my scope. Still I have a question:

  • @support rule.type appears as UNKNOWN_RULE
  • inside that unknown rule I change all colors with string based functions
  • so I end up with a string of a new @support rule
  • is there a way to replace the original UNKNOWN_RULE with the new string I created?

/* UNKNOWN_RULE */
@supports (-webkit-text-stroke: thin) {
    . gradient-color {
        background: linear-gradient(to right, #60c7f2 0%, #00a5e6 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text
    }
}

shall be replaced with

@supports (-webkit-text-stroke: thin) {
    . gradient-color {
        background: linear-gradient(to right, rgba(96,199,242,1) 0%, rgba(0,165,230,1) 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text
    }
}	

How to achieve this?´

The main loop has this form:

for rule in sheet.cssRules: 
	if rule.type in [cssutils.css.CSSRule.UNKNOWN_RULE]:
		rule.style = my_new_string

johanjohan avatar Jul 24 '22 03:07 johanjohan

@johanjohan I'm afraid I don't have enough expertise to provide a good answer. The best I can recommend is to experiment and inspect the code and devise a hack or workable solution.

jaraco avatar Jul 24 '22 15:07 jaraco