Open
Bug 1271520
Opened 9 years ago
Updated 3 years ago
Range.createContextualFragment() for document and document fragment as start node should not throw
Categories
(Core :: DOM: Core & HTML, defect, P3)
Tracking
()
UNCONFIRMED
People
(Reporter: crimsteam, Unassigned)
Details
(Whiteboard: btpp-backlog)
Attachments
(1 file)
1.48 KB,
text/html
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
Build ID: 20160502172042
Steps to reproduce:
When we use document and document fragment as start node (XML/XHTML case) then Gecko throw but should not, now it's inconsistent, depends on document type and start node as type. Some test:
<script>
var str = "<div xmlns='test'></div><p></p>";
var doc = document.implementation.createDocument("http://www.w3.org/1999/xhtml", "body", null);
var range = document.createRange();
range.setStart(document, 0);
console.log(range.startContainer);
var frag = range.createContextualFragment(str);
console.log(frag.childNodes.length);
console.log(frag.firstChild.namespaceURI);
console.log(frag.lastChild.namespaceURI);
range.setStart(document.createDocumentFragment(), 0);
console.log(range.startContainer);
var frag = range.createContextualFragment(str);
console.log(frag.childNodes.length);
console.log(frag.firstChild.namespaceURI);
console.log(frag.lastChild.namespaceURI);
range.setStart(doc.documentElement, 0);
console.log(range.startContainer);
var frag = range.createContextualFragment(str);
console.log(frag.childNodes.length);
console.log(frag.firstChild.namespaceURI);
console.log(frag.lastChild.namespaceURI);
range.setStart(doc, 0);
console.log(range.startContainer);
var frag = range.createContextualFragment(str);
console.log(frag.childNodes.length);
console.log(frag.firstChild.namespaceURI);
console.log(frag.lastChild.namespaceURI);
range.setStart(doc.createDocumentFragment(), 0);
console.log(range.startContainer);
var frag = range.createContextualFragment(str);
console.log(frag.childNodes.length);
console.log(frag.firstChild.namespaceURI);
console.log(frag.lastChild.namespaceURI);
</script>
Gecko throw for two last case, IE11 for 3 last case, Chrome not throw for all. P&S definition (context element is always pass to the parser):
https://www.w3.org/TR/DOM-Parsing/#dfn-dom-range-createcontextualfragment
Reporter | ||
Comment 2•9 years ago
|
||
Edge as Chrome, not throw for all and also set correct namespace for parsed elements.
Reporter | ||
Comment 3•9 years ago
|
||
And also check case when changing namespace for body to:
var doc = document.implementation.createDocument("", "body", null);
Now Gecko/Blink/IE11 throw for 3 last cases but Edge still no.
Comment 4•9 years ago
|
||
It's not clear to me how urgent this is. Arkadiusz, do you have an opinion? Do you, Anne?
Flags: needinfo?(crimsteam)
Flags: needinfo?(annevk)
Whiteboard: btpp-followup-2016-05-17
Reporter | ||
Comment 5•9 years ago
|
||
Honestly nothing urgent, using in HTML document some new documents created via createDocument() is inconsistent in all engines, when I use directly .xhtml file then sometimes get other results. I'm not sure if P&S spec. is correct here, when try compare various command (like createContextualFragment/insertAdjacentHTML/innerHTML in similar scenerio for fragment parsing algorithm) once again I get different results (one throw where other don't). On the other hand working and activity around P&S is close to 0, without more involvement this will never go forward.
Flags: needinfo?(crimsteam)
Comment 6•9 years ago
|
||
Agreed with Arkadiusz. (Thanks for reporting and doing such an excellent job in working through all these API inconsistencies.)
Flags: needinfo?(annevk)
Reporter | ||
Comment 7•9 years ago
|
||
All this problem in Gecko happend because I use "<div xmlns='test'></div><p></p>", when we change data to not has sibling, like "<div xmlns='test'><p></p></div>" then all works fine. But it looks like bug because for innerHTML/outerHTML/insertAdjacentHTML (for the same element as context) this value is accepted and all this method use the same fragment parsing algorithm.
Updated•9 years ago
|
Whiteboard: btpp-followup-2016-05-17 → btpp-backlog
Updated•7 years ago
|
Priority: -- → P3
Assignee | ||
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•