Re: [css4-pseudo] The need for more powerful pseudo elements

On 4/28/13 6:24 AM, François REMY wrote:
> I understand the uses cases but I'm still thinking multiple after/before pseudo-elements isn't the solution we are looking for. Using genereated content for styling is a hack we shouldn't support too much.
>
I disagree.  Although it's ripe for abuse (like most things), this was 
discussed in last week's thread "[css4-pseudo] multiple and nested 
pseudo-element ordering"
iirc, Tab said he supported arbitrarily nested pseudo-elements.

The use case for me, though, was that I had a large amount of metadata 
in data-attributes on an element and wanted to display tags after the 
content (newspaper headlines are the context).  So I'd have

<h3 class="headline" data-content-access="premium" 
data-content-type="video">Stock Prices Plummet</h3>

[data-content-access="premium"]::after(1) {
     content: "VIDEO";
}

[data-content-access="premium"]::after(1)::before {
     content: "V";
     font-family: 'IconFont';
}

That way, I can create a series of ::after()s, each with its own (small) 
tree based on metadata.  This is especially helpful when some of the 
metadata is generated via javascript after the page loads.  We don't 
want to create and append nodes, we'd just like to be able to say 
.setAttribute("data-content-type","blog") and have the rest take care of 
itself.

Moving towards a more semantic web, I think providing complex styling 
and generated content based on metadata is an extremely valid use case.  
And, as a developer at a large media company, I can say that a) this is 
something that is desperately desired, and b) developers are trying to 
move in this direction whether or not the w3c wants them to.

-s

Received on Sunday, 28 April 2013 18:58:06 UTC