WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
148765
prepend should throw when prepending a Text node to Document
https://bugs.webkit.org/show_bug.cgi?id=148765
Summary
prepend should throw when prepending a Text node to Document
Ryosuke Niwa
Reported
2015-09-03 18:08:57 PDT
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
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2015-09-03 18:09:21 PDT
<
rdar://problem/22570226
>
Chris Dumez
Comment 2
2015-09-03 19:13:33 PDT
(In reply to
comment #0
)
> 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
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]
https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
Chris Dumez
Comment 3
2015-09-03 19:15:00 PDT
Maybe you were referring to the following check in the test? === test(function() { var parent = node.cloneNode(); assert_throws('HierarchyRequestError', function() { parent.prepend('text'); }); assert_array_equals(parent.childNodes, []); }, 'Document.prepend() with text as an argument, on a Document having no child.'); === If so, the reason this is expected to throw is because the parent is a Document and the child is a Text Node (step 5 of
https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
).
Ryosuke Niwa
Comment 4
2016-07-15 17:18:20 PDT
Fixed in
https://trac.webkit.org/changeset/189682
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug