Bug 28195

Summary: Inline style wrapped in noscript not applied when added to the DOM via innerHTML
Product: WebKit Reporter: Jonathan Hohle <hohle>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: abarth, ap, hohle
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.5   
Attachments:
Description Flags
HTML to reproduce issue.
none
Actual result when rendering the attached HTML.
none
Expected result when rendering the attached HTML none

Description Jonathan Hohle 2009-08-11 15:37:57 PDT
Created attachment 34605 [details]
HTML to reproduce issue.

If an HTML fragment which contains an inline stylesheet and is wrapped in a noscript tag is added to the DOM by setting innerHTML on a DOM node in JavaScript, those styles are applied to the DOM. 

In my use case an external library is blindly copying HTML fragments which may have reuse elsewhere. Styles that are expected not to be applied when JavaScript is enabled are being applied due to this library using innerHTML to copy this HTML fragment. In other browsers this works as expected, but in Safari, the styles wrapped in noscript are applied causing undesired rendering.

Expected behavior
--------------
Styles wrapped in noscript should be ignored no matter how they are added to the DOM if JavaScript is enabled.

Actual Behavior
------------
Styles wrapped in noscript added to the DOM via innerHTML are applied to the DOM. Styles wrapped in noscript are not applied if they are added to the DOM in an HTML file or via document.write

Reproduction
----------
This has been reproduced in Safari 3.2.x, Safari 4.0.x, and with a current Webkit nightly.

I've attached a minimal HTML file which illustrates the problem.
Comment 1 Jonathan Hohle 2009-08-11 15:39:00 PDT
Created attachment 34606 [details]
Actual result when rendering the attached HTML.
Comment 2 Jonathan Hohle 2009-08-11 15:39:27 PDT
Created attachment 34607 [details]
Expected result when rendering the attached HTML
Comment 3 Alexey Proskuryakov 2009-10-26 09:26:16 PDT
Confirmed with r49890.
Comment 4 Jonathan Hohle 2010-08-02 16:31:58 PDT
Still affects Safari 5.0 (6533.16)
Comment 5 Alexey Proskuryakov 2010-08-16 06:06:49 PDT
This is probably a root cause of bug 13522.
Comment 6 Alexey Proskuryakov 2010-08-16 06:07:23 PDT
But looking at more than its title, maybe not :)
Comment 7 Adam Barth 2010-08-17 21:36:48 PDT
It's the same bug.

*** This bug has been marked as a duplicate of bug 44021 ***