Re: A Call for ::nth-everything

On 11/1/11 9:30 PM, Charles Pritchard wrote:
>> Doing that from script is actually easier, because you don't have to,
>> for every dynamic change to the DOM, check whether it happens to be in
>> the region you're interested in. Especially if you, the author, happen
>> to know that region is completely static. That's something the browser
>> _never_ knows.
>
> I don't understand the demonstration you're describing.
>
> Is it using substr/slice and join of span and associating a class?

I'm not sure I understand the question.

My point is that if you as the page author know your effect is scoped to 
a small part of the DOM, then even if your effect is expensive to set up 
there changes to all other parts of the DOM incur no cost whatsoever.

But the browser has no way to know such things a priori.  The best it 
can do is guess based on the structure of selectors and whatnot.  It's 
not a particularly easy problem.  Furthermore, even if the browser 
guesses right checking whether mutations happen to affect the content 
that you may be styling can end up xpensive.

> The difficulty I'm having is in roles: I don't know when you're talking
> about an author vs. an implementer when you say "Doing that from script
> is actually easier".

In some cases, it is possible for an author to implement an effect in 
script and have it perform better than a similar effect implemented by 
the UA.  This happens because of asymmetrical information: the author 
has a lot more information about what sort of edge cases they do or do 
not care about than the UA does.

> I'm all for being pragmatic. I don't understand why you are labelling
> this as something that would be "purposefully-broken".

Because this involves strictly more performance hit, as far as I can 
see, than things that UAs are _already_ leaving purposefully broken?

Heck, even ::first-letter is broken in some UAs (e.g. Gecko) when some 
dynamic changes are involved.

> I'm discussing the idea in good faith.

I wasn't saying _you_ would purposefully break it.  I'm sorry if you 
perceived it that way....

> CSS has an amazing replaced/generated content spec.

The CSS 2.1 one, or the CSS3 one?  No one implements the latter, and 
implementations of the former are somewhat buggy and inconsistent....

> I don't see why
> advanced styles on letters would be a departure from the precedent set
> in generated content.

I don't think they would be.  They'd just be raising the complexity bar 
a good bit.

> For speed of rendering, as an author, I'd stick with doing things like
> using transform, and I'd stay away from relative positioning. I
> recognize, as an author, that some CSS styles may mean slow performance
> on the page and some CSS styles are quite fast.

I think most authors don't have good understanding here, sadly.  :(

> Wouldn't you agree that this is presentational markup:
> <div><span>H</span><span>e</span><span>y</span></div>
>
> Whereas this is a bit easier on everyone:
> <div>Hey</div>
>
> With the first, I can nth-child, with the second, I could nth-letter.

Sure.  I appreciate the use cases here.  What I'm not certain of are 
that the use cases are sufficiently prevalent to merit the complexity 
this will introduce....  Maybe I'm overestimating the complexity, of course.

-Boris

Received on Wednesday, 2 November 2011 02:27:42 UTC