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
Hi,

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:

http://www.w3.org/TR/webdriver/#determining-visibility

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:

http://www.w3.org/TR/webdriver/#rendering-text

Rationale:

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
code.

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.

Regards,

Simon
Received on Tuesday, 11 September 2012 14:43:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 September 2012 14:43:46 GMT