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'; ```
Note also that the issue is only apparent on a fresh load with no CSS cached.
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.