- From: James Craig <jcraig@apple.com>
- Date: Thu, 09 Oct 2014 10:28:12 -0700
- To: "Gunderson, Jon R" <jongund@illinois.edu>
- Cc: Ted O'Connor <eoconnor@apple.com>, W3C WAI Protocols & Formats <public-pfwg@w3.org>
> On Oct 9, 2014, at 6:34 AM, Gunderson, Jon R <jongund@illinois.edu> wrote:
>
> Is there a way through a W3C DOM interface to identify this generated content?
CSSOM not DOM:
var pseudoBefore = window.getComputedStyle(myElement, "::before");
var genContent = pseudoBefore.getPropertyValue("alt") || pseudoBefore.getPropertyValue("-webkit-alt") || pseudoBefore.getPropertyValue("content");
If "content" returned an image URL string, you'd have to further parse to determine if there was a useful text alternative, or maybe the text or speak-as value of the counter if the content of the pseudo-element was a counter. [1]
>From the spec:
>> If pseudoElt is as an ASCII case-insensitive match for either ':before' or '::before' let obj be the ::before pseudo-element of elt.
>> If pseudoElt is as an ASCII case-insensitive match for either ':after' or '::after' let obj be the ::after pseudo-element of elt.
http://dev.w3.org/csswg/cssom/#dom-window-getcomputedstyle
http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-getpropertyvalue
Cheers,
James
1. http://lists.w3.org/Archives/Public/www-style/2014May/thread.html#msg146
Received on Thursday, 9 October 2014 17:28:40 UTC