- From: Justin Ridgewell via GitHub <sysbot+gh@w3.org>
- Date: Mon, 25 Feb 2019 18:30:03 +0000
- To: public-css-archive@w3.org
> Another question, what should happen if the rule is unparented from a stylesheet? That is, the rule hierarchy has been removed, but somebody still holds a reference to that? I guess it should return true? I think throwing a `TypeError` would be best here. Maybe always false. But maybe just checking if its selector matches would work. But I can't think of a use case that would hold on to a detached rule. > My guess is that the intent of this isn't to find out if an element _could theoretically_ match some rule, but rather to see if it _actually does, at this moment,_ match the rule. Exactly. My intention is to figure out if this rule currently affects my elements style. AMP uses a _really_ complicated system to fix styling bugs with fixed-position elements in Safari. It's easy to see if an element is currently fixed (just a call to `getComputedStyle`). But it's not easy to determine if the element has a defined (not `auto`) top and-or bottom offset. We can only apply our fixes to elements that have a top/bottom. Right now, we do a complicated series of measures and mutates to determine if there's a defined top (measure the top, change bottom to -999999, measure top again, reset bottom, check to see if top changed meaning it was never defined). My hope was to store references to every rule on the page that has a top/bottom, and then iterate until I find that one of them applies to the element. There are edge cases where some later rule could have more specificity and resets the top/bottom, but I'm willing to live with that. -- GitHub Notification of comment by jridgewell Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3670#issuecomment-467124360 using your GitHub account
Received on Monday, 25 February 2019 18:30:05 UTC