[whatwg] HTMLLinkElement.disabled and HTMLLinkElement.sheet behavior

Ian Hickson ian at hixie.ch
Thu Jan 26 16:30:47 PST 2012


On Tue, 4 Oct 2011, Julien Chaffraix wrote:
> 
> following WebKit's attempt at implementing the behavior of |sheet| and 
> |disabled| per HTML5 / CSSOM [1], we have found that the specs [2] [3] 
> either under-specify the behavior or do not match what browsers are 
> doing.

The spec has changed a bit since your e-mail; can you check again and see 
if the improvements are sufficient?


> * Opera and FF always have an associated stylesheet if |link.rel|
> matches a stylesheet and |href| is set.
> * They both fill link.sheet with default values even if the stylesheet
> was / ends up in error.

This is per the spec now.


> * However, FF loads the stylesheet synchronously whereas Opera does it
> asynchronously from a JS perspective

This is required per the spec: a pending <link rel=stylesheet> load does 
block certain scripts from executing.

See: http://www.whatwg.org/specs/web-apps/current-work/#has-a-style-sheet-that-is-blocking-scripts


> * Some websites (4chan.org for examples) assumes that the |sheet| is 
> always available and that |disabled| will work properly regardless of 
> when it is called.

This is now per spec as far as I can tell.

See: http://www.whatwg.org/specs/web-apps/current-work/#styling


On Wed, 5 Oct 2011, Henri Sivonen wrote:
> On Tue, Oct 4, 2011 at 9:54 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
> > What Firefox does do is block execution of <script> tags (but not 
> > timeouts, callbacks, etc!) if there are pending non-altenate 
> > parser-inserted stylesheet loads.  This is necessary to make sure 
> > that scripts getting layout properties see the effect of those 
> > stylesheets. A side-effect is that a <script> coming after a <link> 
> > will never see the link in an unloaded state... unless there's a 
> > network error for the <link> or whatever.
> 
> One exception: If an inline script comes from document.write(), it 
> doesn't block on pending sheets. It runs right away. If it blocked on 
> pending sheets, the point at which document.write() returns would depend 
> on network performance, which I think would be worse than having 
> document.written inline scripts that poke at styles fail depending on 
> network performance.

Note that this is not conforming. The spec does not currently define any 
such behaviour.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list