Bug 14462 - empty <style> element doesn't get a StyleSheet object
Summary: empty <style> element doesn't get a StyleSheet object
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac (Intel) OS X 10.4
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-29 12:41 PDT by Derk-Jan Hartman
Modified: 2010-11-10 13:13 PST (History)
1 user (show)

See Also:


Attachments
First attempt (10.09 KB, patch)
2007-07-14 10:59 PDT, Rob Buis
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Derk-Jan Hartman 2007-06-29 12:41:14 PDT
I was trying to do the following in Javascript

var stylesheet = document.createElement('style');
stylesheet.type = 'text/css';
stylesheet.rel = 'stylesheet';
document.getElementsByTagName("head")[0].appendChild(stylesheet);
var styles = stylesheet.sheet ? stylesheet.sheet : stylesheet.styleSheet;


However this would not work, when testing the value styles, it was null. With help from mitzpettel on #webkit IRC it was determined I needed to add: stylesheet.appendChild(document.createTextNode()); before appending the new style-element to the head-element.
Comment 1 Rob Buis 2007-07-14 10:59:22 PDT
Created attachment 15516 [details]
First attempt

This should fix the problem. I still don't like the StyleElement class 100%, but I think its a bit better now...
Cheers,

Rob.
Comment 2 Maciej Stachowiak 2007-07-16 00:04:40 PDT
Comment on attachment 15516 [details]
First attempt

r=me
Comment 3 Mark Rowe (bdash) 2007-07-16 01:42:22 PDT
I landed this for Rob in r24302.
Comment 4 Alexey Proskuryakov 2010-11-10 13:13:55 PST
I've reverted this fix for bug 45205, but its regression test still passes with ToT.