W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2012

Suggestion: "shown" and "shownText"

From: Simon Stewart <shs@rocketpoweredjetpants.com>
Date: Tue, 11 Sep 2012 15:25:04 +0100
Message-ID: <CAA+kcXzakbcLq0+e0ex3LSddY3xd8nHREJnzcPdSmEj-Rw=xpQ@mail.gmail.com>
To: www-dom@w3.org

As part of the work we're doing on the WebDriver spec, we're attempting to
identify properties or algorithms that may be better placed in other specs.
We think that there are two obvious candidates for inclusion into future
revisions of the DOM spec: "shown" and "shownText".

The "shown" property describes whether a particular element could be made
visible to a user. The algorithm we use to determine this is described in:


The "shownText" property returns the user visible text that corresponds to
what a user would see. The algorithm we use for this is described in:



Of the two, "shownText" may seem the least necessary. After all, there's
already "textContent" and "innerText". The latter isn't standardized, so
cannot be depended on. The former is standardized as being a concatenation
of text nodes. This means that it often contains text that isn't visible to
the user (such as the content of SCRIPT tags, of text that wouldn't be
rendered to the screen due to styling).

In our experience, users tend to use the value of textContent for comparing
large bodies of text spanning several nodes. The current implementation
means that the returned text isn't consistent between different browsers,
and frequently contains output that a user wouldn't see. Worse, tests
sometimes fail because a user compares a string returned from textContent
with what they see on the screen: "I see dead text" is most definitely not
the same as "I see dead \n text" though both are rendered identically.

An implementation of "shownText" would make extensive use of "shown". The
calculations we currently need to perform to implement this cleanly across
browsers cause visibility checks to be extremely expensive. Making this
property available to users via the DOM would also simplify some of the
common operations that people perform currently by checking multiple
properties ("displayed" and "visibility" values, for example) or making use
of custom classes. Even as a read-only property, it could simplify existing

We would be happy to donate the algorithms and a suite of JS-based tests
that demonstrate conformance with the spec if that would help.


Received on Tuesday, 11 September 2012 14:43:35 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:50:42 UTC