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

Commit fbd4884

Browse files
committed
perf(ngRepeat): clone boundary comment nodes
http://jsperf.com/clone-vs-createcomment most of the improvement comes from not reconcatinating the strings
1 parent abb17cc commit fbd4884

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ng/directive/ngRepeat.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
225225
lhs, rhs, valueIdentifier, keyIdentifier,
226226
hashFnLocals = {$id: hashKey};
227227

228+
var ngRepeatEndComment = document.createComment(' end ngRepeat: ' + expression + ' ');
229+
228230
if (!match) {
229231
throw ngRepeatMinErr('iexp', "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",
230232
expression);
@@ -382,7 +384,8 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
382384
// new item which we don't know about
383385
$transclude(function ngRepeatTransclude(clone, scope) {
384386
block.scope = scope;
385-
clone[clone.length++] = document.createComment(' end ngRepeat: ' + expression + ' ');
387+
// http://jsperf.com/clone-vs-createcomment
388+
clone[clone.length++] = ngRepeatEndComment.cloneNode();
386389
$animate.enter(clone, null, jqLite(previousNode));
387390
previousNode = clone;
388391
// Note: We only need the first/last node of the cloned nodes.

0 commit comments

Comments
 (0)