This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 13977 - Check browsers; it might be that links with rel=stylesheet that aren't yet loaded should still have a sheet. See also https://bugs.webkit.org/show_bug.cgi?id=65140
Summary: Check browsers; it might be that links with rel=stylesheet that aren't yet lo...
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-31 04:49 UTC by contributor
Modified: 2011-10-18 03:32 UTC (History)
6 users (show)

See Also:


Attachments

Description contributor 2011-08-31 04:49:16 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/complete.html
Multipage: http://www.whatwg.org/C#styling
Complete: http://www.whatwg.org/c#styling

Comment:
Check browsers; it might be that links with rel=stylesheet that aren't yet
loaded should still have a sheet. See also
https://bugs.webkit.org/show_bug.cgi?id=65140

Posted from: 208.54.39.147 by ian@hixie.ch
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.854.0 Safari/535.2
Comment 1 Boris Zbarsky 2011-08-31 05:29:15 UTC
Ian, if you need a description of Gecko's behavior here at some point, let me know.
Comment 2 Ian 'Hixie' Hickson 2011-10-18 00:32:38 UTC
As far as I can tell:

In IE, <link> loading blocks parsing before the element is added to the DOM.

In Gecko, <link> loading blocks parsing. For rel=stylesheet, a .sheet object is created as soon as the element is created. For other links, e.g. rel="alternate stylesheet" or rel=nothing, .sheet is null.

In WebKit, .sheet is null until the sheet is loaded.

I couldn't work out what Opera was doing.

I think Gecko's idea makes sense and solves the problems raised around this, but why not have a sheet for rel="alternate stylesheet"? (bz?)
Comment 3 Ian 'Hixie' Hickson 2011-10-18 00:32:56 UTC
btw, demo at: http://www.hixie.ch/tests/adhoc/dom/css/StyleSheet/002.html
Comment 4 Ian 'Hixie' Hickson 2011-10-18 00:39:02 UTC
Apparently Opera's just blocking on the .sheet access. That would solve the problem too, but blocking on script execution is something vendors have asked me to avoid.
Comment 5 Boris Zbarsky 2011-10-18 02:32:05 UTC
(In reply to comment #2)
> In Gecko, <link> loading blocks parsing.

No, it does not.

It blocks execution of <script> elements, however.

> For rel=stylesheet, a .sheet object is
> created as soon as the element is created.

That's correct.

> For other links, e.g. rel="alternate stylesheet" or rel=nothing, .sheet is
> null.

"alternate stylesheet" (or indeed any rel value containing "stylesheet" of type="text/css" or no type set) should behave just like rel="stylesheet" in Gecko.  What testcase did you use to determine the above?

Gecko's behavior is basically like this:  Insertion of a <link> (if it's determined to be a CSS stylesheet link via @rel and @type) or <style> element in the DOM immediately creates the .sheet and puts it in the right place in document.styleSheets.  Similar for a mutation to @rel or @type that makes a previously-not-CSS link into a CSS link.

> In WebKit, .sheet is null until the sheet is loaded.

How is "loaded" defined?  If the sheet has @import rules, do those need to be loaded too?  (Think esp. for <style>.)

> I think Gecko's idea makes sense and solves the problems raised around this,
> but why not have a sheet for rel="alternate stylesheet"? (bz?)

We have a sheet for rel="alternate stylesheet" right after insertion into the DOM as far as I know, per above.  Just double-checked with a simple testcase, and it's there...
Comment 6 Ian 'Hixie' Hickson 2011-10-18 02:37:00 UTC
(In reply to comment #5)
> > In Gecko, <link> loading blocks parsing.
> No, it does not.
> It blocks execution of <script> elements, however.

Er, yeah, sorry. I meant in the demo above it blocks parsing, but of course the reason it does that is that it is blocking on execution of the inline script after the link.


> > In WebKit, .sheet is null until the sheet is loaded.
> 
> How is "loaded" defined?  If the sheet has @import rules, do those need to be
> loaded too?  (Think esp. for <style>.)

I didn't investigate this closely, since it's not Web compatible anyway (whence this bug, in fact).
Comment 7 Boris Zbarsky 2011-10-18 02:54:11 UTC
> We have a sheet for rel="alternate stylesheet" right after insertion

Subject to the whole "determined to be a CSS stylesheet link" thing.  In particular, rel="alternate stylesheet" which does not have a nonempty title is NOT considered a CSS stylesheet link in Gecko, which is what the testcase in comment 3 is running into.  I'm not wedded to this, offhand, but it's not quite clear what a browser should do with an alternate stylesheet with no title... (e.g. when is it enabled, if ever?)
Comment 8 Ian 'Hixie' Hickson 2011-10-18 03:23:06 UTC
Ok, I went with what Gecko does.

EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Compat.
Comment 9 contributor 2011-10-18 03:27:01 UTC
Checked in as WHATWG revision r6693.
Check-in comment: Fix compat issue with .sheet and .disabled on external <link>
http://html5.org/tools/web-apps-tracker?from=6692&to=6693
Comment 10 Boris Zbarsky 2011-10-18 03:32:51 UTC
For what it's worth, I believe in Gecko .sheet is also null if @type is set to some value other than "" or "text/css".