bugzilla.mozilla.org has resumed normal operation. Attachments prior to 2014 will be unavailable for a few days. This is tracked in Bug 1475801.
Please report any other irregularities here.

Externally linked stylesheet doesn't have "sheet" attribute

VERIFIED WORKSFORME

Status

()

Core
DOM: CSS Object Model
P3
normal
VERIFIED WORKSFORME
18 years ago
18 years ago

People

(Reporter: Mike Bremford, Assigned: jst)

Tracking

Trunk
All
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

18 years ago
When I link to an external stylesheet like so:

<link href="style.css" type="text/css" rel="stylesheet" id="bing">

I would expect to be able to do document.getElementById("bing").sheet to access 
the stylesheet, but there is no "sheet" attribute.

If I access the stylesheet as document.styleSheets[document.styleSheets.length-
1], I can get back to the HTMLLinkElement via the "ownerNode" property.

Here's some code to reproduce it. Version is M17.

----------------

<html><head>
<link href="NavigationCss.css" type="text/css" rel="stylesheet" id="jim">
<script>
var s = document.getElementById("jim");
var out=s+"\n\n";
for (i in s) {
    out+=i+"='"+s[i]+"'\n";
}
alert (out);

var s = document.styleSheets[document.styleSheets.length-1].ownerNode;
var out=s+"\n\n";
for (i in s) {
    out+=i+"='"+s[i]+"'\n";
}
alert (out);
</script>
</head><body></body></html>
(Assignee)

Comment 1

18 years ago
The stylesheet loading is done asynchronously and thus if you ask for the
stylesheet immediately after the link tag is parsed there will not be a
stylesheet, if you do the same in the documents onload handler (which is really
the first place most scripts should be executed) you'll get a stylesheet.

Marking WONTFIX.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 18 years ago
Hardware: PC → All
Resolution: --- → WONTFIX
(Reporter)

Comment 2

18 years ago
OK, but even then I still get an "undefined".
Here's the code, gives an "undefined" on M17.

<HTML>
<HEAD>
<LINK HREF="/navigation/NavigationCss.jsp" REL="stylesheet" id="bing">
<SCRIPT LANGUAGE="JavaScript">
function x() {
    var s = document.getElementById("bing").sheet;
    alert (s);
}
</script>
</head><body onload=x()>test</body></html>
Status: RESOLVED → UNCONFIRMED
Resolution: WONTFIX → ---
(Assignee)

Comment 3

18 years ago
Please don't file bugs against old builds, download a nightly build and you'll
get 'null' in the alert. --> WORKSFORME
Status: UNCONFIRMED → RESOLVED
Last Resolved: 18 years ago18 years ago
Resolution: --- → WORKSFORME

Comment 4

18 years ago
marking verified using the 2001010310 nightly on win2k.
Status: RESOLVED → VERIFIED
Component: DOM Level 2 → DOM Style
You need to log in before you can comment on or make changes to this bug.