<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>12584</bug_id>
          
          <creation_ts>2011-05-02 22:41:40 +0000</creation_ts>
          <short_desc>outerHTML should probably merge with adjacent text nodes if applicable.  IE seems to do this to some extent, and WebKit just changed to do it: &lt;https://bugs.webkit.org/show_bug.cgi?id=52686&gt; This test shows behavior for outerText and outerHTML: &lt;http://so</short_desc>
          <delta_ts>2015-10-02 01:23:55 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM Parsing and Serialization</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>11204</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Travis Leithead [MSFT]">travil</assigned_to>
          <cc>annevk</cc>
    
    <cc>ayg</cc>
    
    <cc>crimsteam</cc>
    
    <cc>ian</cc>
    
    <cc>keithbrunson</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>public-webapps</cc>
    
    <cc>shadow2531</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>47849</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-05-02 22:41:40 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/apis-in-html-documents.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#outerhtml

Comment:
outerHTML should probably merge with adjacent text nodes if applicable.  IE
seems to do this to some extent, and WebKit just changed to do it:
&lt;https://bugs.webkit.org/show_bug.cgi?id=52686&gt; This test shows behavior for
outerText and outerHTML:
&lt;http://software.hixie.ch/utilities/js/live-dom-viewer/saved/971&gt; (Opera never
merges, IE9 merges for outerText and partially merges for outerHTML, WebKit
now fully merges for both, Gecko doesn&apos;t implement either)

Posted from: 68.175.61.233
User agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.12 Safari/534.30</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53805</commentid>
    <comment_count>1</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:17:30 +0000</bug_when>
    <thetext>mass-move component to LC1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123421</commentid>
    <comment_count>2</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2015-10-01 18:55:47 +0000</bug_when>
    <thetext>If it is taken into account then analyze more tescase, because for IE I noticed different behaviour (depending on how the tree was constructed).

&lt;script&gt;

	var container = document.createElement(&quot;div&quot;);
	container.appendChild(document.createTextNode(&quot;Text node 1&quot;));
	container.appendChild(document.createTextNode(&quot;Text node 2&quot;));
	
	var newEl = document.createElement(&quot;div&quot;);
	newEl.textContent = &quot;Element content&quot;;
	container.appendChild(newEl);
	
	container.appendChild(document.createTextNode(&quot;Text node 3&quot;));
	container.appendChild(document.createTextNode(&quot;Text node 4&quot;));
	
	alert(container.childNodes.length);
	
	container.childNodes[2].outerHTML = &quot; outerHTML &quot;;
	
	alert(container.childNodes.length);
	alert(container.childNodes[1].data);

&lt;/script&gt;

Firefox, Opera (Presto) alerts: 5, 5, Text node 2 &lt;&lt; not merge anything

Chrome alerts: 5, 3, Text node 2 outerHTML Text node 3 &lt;&lt; merge previous and next sibling (only text node) if exist

IE11 alerts: 5, 4, Text node 2 outerHTML &lt;&lt; merge previous sibling (only text node) if exist, but if not exist and exist next sibling (only text node) then merge with them. This is not the same what we see in example from comment0.

But if merge will became standarized then what merge, only previous and next sibling (text node) or all contiguous Text nodes (https://dom.spec.whatwg.org/#contiguous-text-nodes)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123432</commentid>
    <comment_count>3</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2015-10-02 01:23:55 +0000</bug_when>
    <thetext>One more thing, IE11 also merge text nodes for Element.insertAdjacentHTML(), but Chrome and Firefox no.

&lt;script type = &quot;text/javascript&quot;&gt;

	var container = document.createElement(&quot;div&quot;);
	container.appendChild(document.createTextNode(&quot;Text node 1&quot;));
	container.appendChild(document.createTextNode(&quot;Text node 2&quot;));
	container.appendChild(document.createElement(&quot;div&quot;));
	
	container.childNodes[2].insertAdjacentHTML(&quot;beforebegin&quot;, &quot; Parsed text&quot;);
	alert(container.childNodes.length);
	alert(container.childNodes[1].data);

&lt;/script&gt;

Firefox, Chrome alerts: 4, Text node 2
IE11 alerts: 3, Text node 2 Parsed text

I&apos;m opposite for merging text node in all this cases, they change node tree without possibility of control this behaviour. If someone want clean up tree then can use Node.normalize() or other way (how he want). There is no need to complicate this more.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>