Re: Styling by attribute-based association?

Ian Hickson wrote:
>    label:friend(for, [type=date]) { ... }
> 
> ...would select all labels pointing at elements with type="date".
> 
> This selector wouldn't be expensive to process, particularly (it wouldn't 
> be cheap, but it doesn't have the potential to run away scanning the 
> entire DOM tree or anything, assuming IDs are cached).

This selector is not expensive to match on if you're already resolving 
style for the element.  It's expensive in the face of dynamic updates, 
though.  Whenever a node is removed from the DOM or the ID of a node 
changes, you have to walk the whole DOM looking for labels that pointed 
to the old id and changing their style.

That is, this selector is good at defeating attempts to not recompute 
style for the entire DOM on DOM mutations.

-Boris

Received on Tuesday, 25 October 2005 21:34:53 UTC