[Webkit-unassigned] [Bug 249737] New: Setting outerHTML on child of DocumentFragment throws error

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 21 12:15:41 PST 2022


https://bugs.webkit.org/show_bug.cgi?id=249737

            Bug ID: 249737
           Summary: Setting outerHTML on child of DocumentFragment throws
                    error
           Product: WebKit
           Version: Safari Technology Preview
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: DOM
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: nlawson at salesforce.com

Created attachment 464152

  --> https://bugs.webkit.org/attachment.cgi?id=464152&action=review

Repro HTML

Steps to repro:

1. Go to https://codepen.io/nolanlawson-the-selector/pen/oNMgmXe
2. Notice that it says an error was thrown

Minimal repro:

    const fragment = new DocumentFragment()
    fragment.appendChild(document.createElement('div'))
    fragment.firstChild.outerHTML = ''

In Firefox this does not throw an Error. In Safari Technology Preview Release 146 (Safari 15.4, WebKit 16614.1.14.10.6), it throws an error:

> Cannot set outerHTML on element because its parent is not an Element

According to the spec [1]:

> If parent is a DocumentFragment, let parent be a new Element […]

So it appears that Firefox is following the spec here, but Safari is not.

Note that my repro tests both a DocumentFragment and a ShadowRoot. Since a ShadowRoot is an instance of DocumentFragment, neither test should throw an error.

Same bug filed on Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=1403060

[1]: https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20221221/2cce5b1b/attachment.htm>


More information about the webkit-unassigned mailing list