<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Page fails to update CSS sometimes when styles are dynamically injected into the page"
href="https://bugs.webkit.org/show_bug.cgi?id=145244">145244</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Page fails to update CSS sometimes when styles are dynamically injected into the page
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>528+ (Nightly build)
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh Intel
</td>
</tr>
<tr>
<th>OS</th>
<td>Mac OS X 10.10
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>Layout and Rendering
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dak@dak.org
</td>
</tr></table>
<p>
<div>
<pre>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 <a href="http://32demclub.com">http://32demclub.com</a> (code at <a href="https://github.com/DerekKent/32demclub/tree/d0b2dd6dc146b40ea2a7541f1e46522e7eda7711/dist">https://github.com/DerekKent/32demclub/tree/d0b2dd6dc146b40ea2a7541f1e46522e7eda7711/dist</a>).
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';
```</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>