This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29175 - Special rules for HTML element in HTML document for Element.insertAdjacentHTML() are necessary?
Summary: Special rules for HTML element in HTML document for Element.insertAdjacentHTM...
Status: NEW
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM Parsing and Serialization (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Travis Leithead [MSFT]
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-03 02:24 UTC by Arkadiusz Michalski (Spirit)
Modified: 2016-05-05 12:05 UTC (History)
3 users (show)

See Also:


Attachments

Description Arkadiusz Michalski (Spirit) 2015-10-03 02:24:02 UTC
Firefox is the only current browser which complies these requirements (step 2.)?
http://www.w3.org/TR/DOM-Parsing/#dfn-dom-element-insertadjacenthtml

Small test:

<script type = "text/javascript">

	var newFragment = document.createDocumentFragment();
	newFragment.appendChild(document.createElement("html"));
	
	newFragment.firstChild.insertAdjacentHTML("afterbegin", "<p>test");
	alert(newFragment.firstChild.innerHTML);

</script>

Firefox, IE6/IE7/IE8/ : <p>test</p>
Chrome, IE11, Opera (Presto): <head></head><body><p>test</p></body>

I don't have access to Safari, what WebKit returns? What Edge returns?
Comment 1 Boris Zbarsky 2015-10-05 03:20:46 UTC
> what WebKit returns?

Same thing as Chrome and IE11.

> What Edge returns?

Again, the same thing as Chrome and IE11, as far as I can tell.
Comment 2 Arkadiusz Michalski (Spirit) 2016-05-05 11:49:34 UTC
Basically this step 2. is correct in other browsers excluding one case (when we invoke method on <html> whose parent is DocumentFragment) because they don't change context to <body>, like we see in https://www.w3.org/Bugs/Public/show_bug.cgi?id=29175#c0.

But in other site actuall definitions in P&S are consistent because fit to Element.outerHTML and Range.createContextualFragment() in simillar cases (when used on <html> as object context). For this commands Firefox is still correct, other browsers are more or less correct (they have other inaccuracies).
Comment 3 Arkadiusz Michalski (Spirit) 2016-05-05 12:05:35 UTC
And small test:

<script type = "text/javascript">
	var range = document.createRange();
	var newFragment = document.createDocumentFragment();
	newFragment.appendChild(document.createElement("html"));
	range.setStart(newFragment.firstChild, 0);
	alert(new XMLSerializer().serializeToString(range.createContextualFragment("<p>test")));

	newFragment = document.createDocumentFragment();
	var html = document.createElement("html");
	var head = document.createElement("head");
	html.appendChild(head);
	newFragment.appendChild(html);
	head.outerHTML = "<p>aaa";
	alert(new XMLSerializer().serializeToString(newFragment));

	// Chrome throw here so I put this test at the end
	newFragment = document.createDocumentFragment();
	newFragment.appendChild(document.createElement("html"));
	newFragment.firstChild.outerHTML = "<p>test";
	alert(new XMLSerializer().serializeToString(newFragment));
</script>