W3C home > Mailing lists > Public > www-style@w3.org > December 2011

Re: [css4-ui]/[css4-selectors] Pseudo-class for selecting broken images & other external resources

From: François REMY <fremycompany_pub@yahoo.fr>
Date: Thu, 29 Dec 2011 11:48:48 +0100
Message-ID: <8F04EB17004445FFB09514EDBC49F932@FREMY2>
To: "Tab Atkins Jr." <jackalmage@gmail.com>, "Brian Kardell" <bkardell@gmail.com>
Cc: "www-style list" <www-style@w3.org>, "Lea Verou" <leaverou@gmail.com>
Yes, a script can handle the case of an XHR request *it initiated*, and it 
has to. But sometimes, you just use an async SCRIPT tag to an external 
service that may fail to load for reasons you can't explain (too heavy load, 
http error, script disabled...). You have no control over that process. 
There's no "onerror" you can watch for. In the best case, there's an 
"onload".

At this time, you can't know if the script is "still downloading" or "has 
been aborted". If the script fails to load, you would like to display an 
error message to the user. While the script is still downloading, you would 
like to display a "Loading" message, or hide the dynamic content placeholder 
until it has something to display. Do you really have to do this using a 
script? A script should be responsible of what it initiated, but there must 
be a way for a document to react on the download faillure of its own content 
without using a script, that could fail to load too.

I feel like CSS is able to handle such cases perfectly and is more efficient 
to do this that any script you could use (BTW, if you rely on scripting to 
display error messages you takes the risk of failling to notice faillure if 
scripting was disabled).

Additionnaly, a "uninitialized/loading/loaded/error" state is applyable on 
many content types (IMG, VIDEO, SCRIPT, LINK...) and can be used to define 
fallback behaviors that are far more complex than just "another fallback 
content" as you proposed in your last mail. You could decide to hide a DIV 
containing an image that failled to load. You could decide to display a 
message while a video is still loading. You may want to show a message to 
the user if the video failled to load. You can probably do all this by 
script, but I feel like it's a job for the CSS engine, not for a script.





-----Message d'origine----- 
From: Tab Atkins Jr.
Sent: Thursday, December 29, 2011 1:39 AM
To: Brian Kardell
Cc: www-style list ; Lea Verou
Subject: Re: [css4-ui]/[css4-selectors] Pseudo-class for selecting broken 
images & other external resources

On Wed, Dec 28, 2011 at 4:02 PM, Brian Kardell <bkardell@gmail.com> wrote:
> That only covers images, I think the point made and reiterated throughout
> was that this would be a nice feature for any external resource, so while
> that is a significant step forward from where we are today, it seems yes
> there are numerous cases that this would not cover...

Yes, another use-case presented was displaying an error message based
on script-loading status.  This is complex in different ways, though.
For example, XHRs are used in the same context as <script>-based
loading, and would benefit in the same way (perhaps EventSources as
well).  There's no DOM element associated with an XHR, though, so you
can't just use a pseudoclass on an element to indicate this.  One
possible approach around this is to somehow associate loads with an
identifier and then use the ident in a pseudoclass, so that arbitrary
data loads can be hooked on.

On the other hand, hooking the error events in JS and updating, say,
an attribute on the body (for use in targetting selectors) is pretty
easy, works for all the various data-loading mechanisms, and can be
done today.  Are there ways we can make this easier, and would it be
worthwhile to expend the effort (in speccing, testing, and
implementing) to do so?

~TJ 
Received on Thursday, 29 December 2011 10:49:16 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:47 GMT