Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

perf($compile): only use document fragments when necessary #12041

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2494,9 +2494,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
parent.replaceChild(newNode, firstElementToRemove);
}

// TODO(perf): what's this document fragment for? is it needed? can we at least reuse it?
var fragment = document.createDocumentFragment();
fragment.appendChild(firstElementToRemove);
// If multiple elements are being replaced put them into a temporary fragment
// so they can still be traversed with .nextSibling or .parent.children while detached.
var fragment;
if (removeCount > 1) {
fragment = document.createDocumentFragment();
fragment.appendChild(firstElementToRemove);
}

// Copy over user data (that includes Angular's $scope etc.). Don't copy private
// data here because there's no public interface in jQuery to do that and copying over
Expand Down