Bug 145244
| Summary: | Page fails to update CSS sometimes when styles are dynamically injected into the page | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | dak |
| Component: | Layout and Rendering | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | dak |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | Mac (Intel) | ||
| OS: | OS X 10.10 | ||
dak
WebKit is apparently failing to update its CSS and redraw the page when <style> tags are dynamically injected into a page.
In the failing code, the <style> tags are being injected inside of the body tag (as <style scoped> — scoped isn't supported yet, but the styles should still apply globally). I've not yet confirmed whether or not this is a necessary condition for the issue.
I've been attempting to create a simplified test case for this issue, but have so far been unable to do so. There may be an element of complexity/timing necessary for the issue to manifest itself. At the moment, the issue can be seen at http://32demclub.com (code at https://github.com/DerekKent/32demclub/tree/d0b2dd6dc146b40ea2a7541f1e46522e7eda7711/dist).
I'll update this issue with a test case if/when I'm able to produce one.
Running the following code after the page has rendered fixes the issue:
```
// Updates the CSS, but some DOM elements are missing
var head = $('head');
var style = $('<style>');
head.append(style);
style.remove();
// Restores missing DOM elements
$('#main').get(0).parentNode.style.cssText += ';-webkit-transform:rotateZ(0deg)';
$('#main').get(0).parentNode.offsetHeight;
$('#main').get(0).parentNode.style.cssText += ';-webkit-transform:none';
```
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
dak
Note also that the issue is only apparent on a fresh load with no CSS cached.
dak
It appears that under certain conditions, injected stylesheets are not initially appearing in `document.styleSheets` when injected with a <style> tag somewhere other than the <head>.
Forcing the styles to be recalculated fixes the issue.