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)

40 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: crimsteam, Unassigned)

Details

(Whiteboard: btpp-backlog)

Attachments

(1 file)

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
Attached file 1271520.html
Edge as Chrome, not throw for all and also set correct namespace for parsed elements.
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.
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
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)
Agreed with Arkadiusz. (Thanks for reporting and doing such an excellent job in working through all these API inconsistencies.)
Flags: needinfo?(annevk)
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.
Whiteboard: btpp-followup-2016-05-17 → btpp-backlog
Priority: -- → P3
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: