<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - prepend should throw when it's called on a node without children"
href="https://bugs.webkit.org/show_bug.cgi?id=148765#c2">Comment # 2</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - prepend should throw when it's called on a node without children"
href="https://bugs.webkit.org/show_bug.cgi?id=148765">bug 148765</a>
from <span class="vcard"><a class="email" href="mailto:cdumez@apple.com" title="Chris Dumez <cdumez@apple.com>"> <span class="fn">Chris Dumez</span></a>
</span></b>
<pre>(In reply to <a href="show_bug.cgi?id=148765#c0">comment #0</a>)
<span class="quote">> document.createElement('div').prepend(document.createElement('span')) should
> throw HierarchyRequestError when ensureing pre-insertion validity.
>
> This bug was found by the newly added test:
> LayoutTests/http/tests/w3c/dom/nodes/prepend-on-Document.html</span >
The case you're mentioning seems like it should work and I don't see anything in the spec [1] saying it shouldn't. Looking at http/tests/w3c/dom/nodes/prepend-on-Document.html, I see the following test case:
===
test(function() {
var parent = node.cloneNode();
var x = document.createElement('x');
parent.prepend(x);
assert_array_equals(parent.childNodes, [x]);
}, 'Document.prepend() with only one element as an argument, on a Document having no child.');
===
This seems to be the case you mention and the test does not expect an exception.
[1] <a href="https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity">https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>