Improve [attr~="value"] selector (attribute contains word)
Instead of first splitting attribute value into words, and then
checking that one of words is equal to given value
grep { $_ eq $value } split ' ', $attr;
use regexp anchored to words boundary for word matching
/\b\Q$value\E\b/
Strictly speaking it makes [attr=~"value"] selector not conformant to
CSS2+ specification, but it shouldn't matter in real life. See
http://www.w3.org/TR/CSS2/selector.html#attribute-selectors
[att~=val]
[..] If "val" contains white space, it will never represent anything
(since the words are separated by spaces). If "val" is the empty
string, it will never represent anything either.
Suggested-by: Matt S Trout <mst@shadowcat.co.uk>