Re: [whatwg/dom] Hook for SVG and HTML script element insertion (#575)

> Oh joy, if I change things to
> 
> ```html
> <!DOCTYPE html>
> <script>
>  var s1 = document.createElement("script"); s1.textContent = "w(1 + ' ' + document.head.childElementCount); document.head.removeChild(s2)"
>  var s2 = document.createElement("script"); s2.textContent = "w(2 + ' ' + document.head.childElementCount + ' ' + s2.parentNode)"
>  var df = document.createDocumentFragment(); df.appendChild(s1); df.appendChild(s2)
>  document.head.appendChild(df)
> </script>
> ```
> _s2_ will not execute in Chrome and Edge, but does execute in Firefox. Safari will throw an error for _s1_ because in Safari _s2_ is not in the tree yet when _s1_ executes.
> 
> So maybe another thing that's needed here is that `script` elements without parent do not execute?

Safari follows the current spec entirely for this one snippet, here is what the Live DOM Viewer says:

```
log: 1 1
error: NotFoundError: The object can not be found here. on line 1
log: 2 2 [object HTMLHeadElement]
```

Which means it first inserts `s1` and runs it, which raises a `NotFoundError` because `s2` is not a child of `head`, then it inserts `s2` and runs it.

I'm not really sure what to do with this information, in which way do we want the spec to go? Do we want to specify less differences between inserting a `DocumentFragment` and a plain old node?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/575#issuecomment-460216453

Received on Monday, 4 February 2019 11:33:03 UTC