angular/angular.js — pull request #9365 by jbedard (2014-10-01 09:20:37+00:00)
Title: perf($compile): only use document fragments and copy data when necessary (replaceWith)

This does a few things, all within the internal `replaceWith`...

* only creates the document fragment if needed and clarifies why it's there
* only copies data if the node `hasData` to avoid creating empty data to copy (a jqLite version of `hasData` was added)
* uses the static data methods to avoid creating jqLite/jQuery objects
* cleans the data of all replaced elements the same way (this will no longer trigger $destroy on nodes 1+, like node 0, which seems correct to me)
* uses jqLite/jQuery/Array.splice to do the array modifications