Re: Select elements based on text content

On 30 March 2010 05:28, Gabriele Romanato <gabriele.romanato@gmail.com>wrote:

This is somewhat that browser implementors would define "expensive", because
> it actually requires a full access to the DOM structure before the DOM is
> complete.
>

On 30 March 2010 11:11, Boris Zbarsky <bzbarsky@mit.edu> wrote:

In general, the use of such a selector would cause significant slowdowns in
> web page rendering (esp. incremental rendering).
>

That's interesting. I have very little understanding of how selectors work
behind the scenes, and had assumed that selecting elements based on their
text content would be no more difficult than selecting elements based on an
attribute value.

Thanks to the quoted responses, I believe that I now have an understanding
of why selecting elements based on their text content is a slower operation.

Without text content matching:

    <td class="unsupported">(browser can determine at this point which
selectors match this td)

With text content matching:

    <td class="unsupported">(browser unable to determine at this point which
selectors match this td)No</td>(browser can determine at this point which
selectors match this td)

Have I understood the problem correctly?

David

Received on Tuesday, 30 March 2010 00:52:12 UTC