Fixes #10515 - Implementation of iAH

Based on @dmethvin <a href="https://github.com/jquery/jquery/pull/1095">idea</a>.
By opening this PR, i want, one way or another, to close <a href="http://bugs.jquery.com/ticket/10515">#10515</a>, but i'm not sure what a resolution of that ticket should be.

<h3>Perf tests</h3>
<dl>
<dt><code>jQuery.append</code></dt>
<dd><ul>
<li><a href="http://jsperf.com/jq-iah-append">big HTML-string</a></li>
<li><a href="http://jsperf.com/jq-iah-append/2">small HTML-string</a></li>
<li><a href="http://jsperf.com/jq-iah-append/3">big HTML-string, hidden element</a></li>
<li><a href="http://jsperf.com/jq-iah-append/9">small HTML-string, hidden element</a></li>
<li><a href="http://jsperf.com/jq-iah-append/7">big HTML-string, disconnected element</a></li>
<li><a href="http://jsperf.com/jq-iah-append/6">small HTML-string, disconnected element</a></li>
</ul></dd>

<dt><code>jQuery.prepend</code></dt>
<dd><ul>
<li><a href="http://jsperf.com/jq-iah-prepend">big HTML-string</a></li>
<li><a href="http://jsperf.com/jq-iah-prepend/2">small HTML-string</a></li>
<li><a href="http://jsperf.com/jq-iah-prepend/3">big HTML-string, hidden element</a></li>
<li><a href="http://jsperf.com/jq-iah-prepend/8">small HTML-string, hidden element</a></li>
<li><a href="http://jsperf.com/jq-iah-prepend/7">big HTML-string, disconnected element</a></li>
<li><a href="http://jsperf.com/jq-iah-prepend/6">small HTML-string, disconnected element</a></li>
</ul></dd>

<dt><code>jQuery.before</code></dt>
<dd><ul>
<li><a href="http://jsperf.com/jq-iah-before">big HTML-string</a></li>
<li><a href="http://jsperf.com/jq-iah-before/2">small HTML-string</a></li>
<li><a href="http://jsperf.com/jq-iah-before/3">big HTML-string, hidden element</a></li>
<li><a href="http://jsperf.com/jq-iah-before/6">small HTML-string, hidden element</a></li>
<li><a href="http://jsperf.com/jq-iah-before/7">big HTML-string, disconnected element</a></li>
<li><a href="http://jsperf.com/jq-iah-before/8">small HTML-string, disconnected element</a></li>
</ul></dd>

<dt><code>jQuery.after</code></dt>
<dd><ul>
<li><a href="http://jsperf.com/jq-iah-after">big HTML-string</a></li>
<li><a href="http://jsperf.com/jq-iah-after/2">small HTML-string</a></li>
<li><a href="http://jsperf.com/jq-iah-after/3">big HTML-string, hidden element</a></li>
<li><a href="http://jsperf.com/jq-iah-after/7">small HTML-string, hidden element</a></li>
<li><a href="http://jsperf.com/jq-iah-after/4">big HTML-string, disconnected element</a></li>
<li><a href="http://jsperf.com/jq-iah-after/6">small HTML-string, disconnected element</a></li>
</ul></dd>
</dl>

<h3>What's the takeaway?</h3>
This is a difference between <code>iAH</code> methods and current DOM-manipulation tactics –

<table>
<tr>
    <th>Conditions</th>
    <th>Results</th>
</tr>

<tr>
    <td>Big HTML-string, attached element</td>
    <td>Small speed increase in almost all browsers, considerable speed decrease in WebKit</td>
</tr>

<tr>
    <td>Small HTML-string, attached element</td>
    <td>All browsers shown good speed increase</td>
</tr>

<tr>
    <td>Big HTML-string, hidden element</td>
    <td>Slightly better results</td>
</tr>

<tr>
    <td>Small HTML-string, hidden element</td>
    <td>All browsers shown good speed increase</td>
</tr>

<tr>
    <td><code>jQuery#append/prepend</code>, big/small HTML-string, disconnected element</td>
    <td>Either equal or slightly better results</td>
</tr>

<tr>
    <td><code>jQuery#before/after</code>, big HTML-string, disconnected element</td>
    <td>Slightly better results for most cases, except Opera performed slightly worse</td>
</tr>

<tr>
    <td><code>jQuery#before/after</code>, small HTML-string, disconnected element</td>
    <td>All browsers shown good speed increase</td>
</tr>

</table>

<h3>Perf hit</h3>
In some situations <code>insertAdjacentHTML</code> method could not be applied, guards for that cases will slow down <code>jQuery#domManip</code> method –
<ul>
<li>If first argument for <code>iAH</code> is either <code>beforebegin</code> or <code>afterend</code> (affect <code>jQuery#before/after</code>), <code>insertAdjacentHTML</code> could not be applied if target element does not have parent element (obviously) or that element is document fragment (less obvious), although <code>iAH</code> could be used if first argument is <code>afterbegin</code> or <code>beforeend</code> (<code>jQuery#append/prepend</code>) for such an element, but it would reguire additional check inside <code>for</code> loop. Perf hit for <code>jQuery#append/prepend</code> methods applied to parentless element would be:
<ul>
<li><code>jQuery#append</code> – <a href="http://jsperf.com/jq-iah-append/4">big</a>/<a href="http://jsperf.com/jq-iah-append/5">small</a> HTML-string</a></li>
<li><code>jQuery#prepend</code> – <a href="http://jsperf.com/jq-iah-prepend/4">big</a>/<a href="http://jsperf.com/jq-iah-prepend/5">small</a> HTML-string</a></li>
</ul>
</li>

<li>HTML-string in IE9, could not be inserted to <code>table</code> element through <code>insertAdjacentHTML</code> method, plus in other browsers, that code path perform <a href="http://jsperf.com/iah-to-table">worse</a> then current way. Perf hit for bypassing <code>table</code> element as target node would be – <a href="http://jsperf.com/iah-to-table/3">http://jsperf.com/iah-to-table/3</a></li>

<li>Sometimes HTML-string must be wrapped, like when creating <code>tr</code> element, in such case if <code>insertAdjacentHTML</code> is not applied to <code>table</code> element that code would silently <a href="http://jsfiddle.net/tQ4K2/">fail</a>, therefore for that cases <code>iAH</code> path must not be taken, perf hit will be the same as for above <code>table</code> example</li>

<li><code>iAH</code> could not take <code>object</code> as an argument. Perf hit by circumventing <code>object</code> as an argument would be – <a href="http://jsperf.com/jq-iah-append-object">http://jsperf.com/jq-iah-append-object</a></li>

<li><code>document fragment</code> (and all other types of an node) does not have <code>insertAdjacentHTML</code> method, also <code>script</code> element should not be inserted that way. Perf hit for that cases would be – http://jsperf.com/jq-iah-append-to-documentfragment</li>
</ul>

<h4>As conclusion</h4>
Performance ratio of WebKit <code>iAH</code> in case of big HTML-string relative to current DOM-manipulation way is utterly depressing, one might even suggest that this happens due to regexp check, but it's not the <a href="http://jsperf.com/iah-append/5">case</a> – in that version of a <code>iAH</code> implementation regexp check is removed, which does not heavily change the picture. Solution for that problem might be size check of HTML-string.

Use of <code>jQuery#append</code> as an example of that idea – <a href="http://jsperf.com/jq-iah-append-limited-html">big</a>/<a href="http://jsperf.com/jq-iah-append-limited-html/2">small</a> HTML-string. This control is flatten disproportion in WebKit case, but it also decrease performance in other browsers.

I suppose big HTML-string is rarely acts as argument in jQuery's DOM-manipulation methods, maybe only in case when whole page should be reflowed, besides, 184 operation per second might be fast enough for that task, ergo it might be more productive to dwell on more optimistic small HTML-string's cases, given the idea that if whether or not <code>iAH</code> should be employed was made only by proceeding outcome most of other samples then decision would be little more obvious? As of perf hit examples (see above) – some of them are rare edge cases, some of them do not matter that much and some of them aren't that conclusive.

But considering all that, i'd say this research is showed a lot of arguments to not use <code>iAH</code> inside of <code>jQuery#domManip</code> at all.