<div><meta charset="utf-8">On Thu, Nov 11, 2010 at 5:48 PM, Jonas Sicking <span dir="ltr"><jonas@sicking.cc></span> wrote:<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
When setting .innerHTML browsers always have prevented any created<br><script>s from running. We ended up copying this behavior from IE when<br>we originally implemented .innerHTML in firefox (then netscape) since<br>
sites were relying on it.<br><br>In particular sites were doing things like<br><br>a.innerHTML = b.innerHTML;<br>and<br>a.innerHTML += "<b>what's up dog</b>"; (btw, perf-wise this is<br>terrible, but people do do it).<br>
<br>and in both cases fell over when scripts in a "re-executed". So your<br>example above should not alert if you want your browser to be<br>compatible with the web.<br></blockquote><div><br></div><div>Ok, so we agree on this case.</div>
<div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
For range.createContextualFragment things are different though. (The<br>function returns a fragment, and so its obvious that script should<br>never execute *during* exeuction of createContextualFragment, the<br>question is if they should execute if that fragment is later inserted<br>
in a document).<br></blockquote><div><br></div><div>I don't think we should execute either. Why should we treat fragments created by createContextualFragment differently from fragments created by innerHTML? That sounds arbitrary and confusing.</div>
<div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
First off, there is no spec for createContextualFragment so there is<br>no spec text to turn to.<br></blockquote><div><br></div><div><meta charset="utf-8">On Thu, Nov 11, 2010 at 10:22 PM, Henri Sivonen <span dir="ltr"><<a href="mailto:hsivonen@iki.fi">hsivonen@iki.fi</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
<div class="im">> First off, there is no spec for createContextualFragment so there is<br>> no spec text to turn to.<br><br></div>There is now:<br><a href="http://html5.org/specs/dom-parsing.html#extensions-to-the-range-interface" target="_blank">http://html5.org/specs/dom-parsing.html#extensions-to-the-range-interface</a></blockquote>
<div><br></div></div><div>According to the part of spec Heri referenced, we should NOT run scripts in a fragment created by createContextualFragment either because we invoke the same HTML fragment parsing algorithm, which sets "already started" flag before inserting the script element into the document.</div>
<div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
* Firefox has always left scripts created using<br>createContextualFragment as executable. So web compatibility would </blockquote><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
speak for making the scripts executable.<br></blockquote><div><br>Opera seems to execute scripts created by createContexualFragment as well.</div><div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
* It seems somewhat weird to single out script elements as being the<br>only ones to receive special treatment by disabling them. Things like<br>onclick attributes are still enabled.<br></blockquote><div><br></div><div>But we already do this for innerHTML. I don't think it's weird to single out script elements given the security implications.</div>
<div> </div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
* Since scripts don't execute synchronously from within<br>createContextualFragment the caller doesn't have to deal with weird<br>reentrancy issues during parsing.<br></blockquote><div><br></div><div>Sure but that means we have to special-case fragments created by createContexualFragment. That adds extra complexity to the HTML fragment parsing algorithm.</div>
<meta charset="utf-8"><div><br></div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
For these reasons we decided to keep Firefox 4 behaving like previous<br>versions of firefox and allow scripts created using<br>createContextualFragment to execute.<font class="Apple-style-span" color="#888888"><br></font></blockquote>
<div><br></div></div><div><meta charset="utf-8">However, Firefox 4.0 Beta 6 does not execute the script as far as I tested. Try opening <a href="http://dscoder.com/MessageStyle/testcase.html">http://dscoder.com/MessageStyle/testcase.html</a></div>
<div><br></div><div>- Ryosuke Niwa</div>