3.org/TR/CSS21/selector.html">selector types (where "SN" is shorthand for "the selected node"):
- Universal (i.e. "*"): Affected by the removal of SN from the document.
- Type (i.e. "div"): Affected by the removal of SN from the document.
- Descendant (i.e. "div span"): Affected by changes to SN or to any of its ancestors.
- Child (i.e. "div > span"): Affected by changes to SN or to its parent.
- Adjacent Sibling (i.e. "table + p"): Affected by changes to SN or its previous sibling.
- Attribute (i.e. "div.up, div[class~=up]"): Affected by changes to an attribute of SN.
- ID (i.e. "#header): Affected by changes to the id attribute of SN.
- Pseudo-Elements and Pseudo-Classes (i.e. "p:first-child"): Affected by changes to parent.
Together, these rules dictate that the smart (but still lazy) way of removing elements from the computed style cache is as follows -- whenever a node changes in any way, the cache needs to be cleared of styles for nodes which:
- are actually the same node as the node that changed
- are siblings of the node that changed
- are descendants of the node that changed
Additionally, whenever a style node or a link node with rel=stylesheet is added or removed, all elements should be removed from the computed style cache.