NEW145244
Page fails to update CSS sometimes when styles are dynamically injected into the page
https://bugs.webkit.org/show_bug.cgi?id=145244
Summary Page fails to update CSS sometimes when styles are dynamically injected into ...
dak
Reported 2015-05-20 22:30:32 PDT
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
dak
Comment 1 2015-05-20 22:35:16 PDT
Note also that the issue is only apparent on a fresh load with no CSS cached.
dak
Comment 2 2015-05-21 06:46:14 PDT
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.
Note You need to log in before you can comment on or make changes to this bug.