aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIgor Minar2011-03-28 17:51:51 -0700
committerIgor Minar2011-03-30 15:24:03 -0700
commit15ec78f5eff3f8fa74714fe10986be094915c800 (patch)
treefe527b3cfe1bec20c371fae2113f62500823ad14 /src
parenta4863d52448170a8b94fa1fd2df79af1b66b6ad1 (diff)
downloadangular.js-15ec78f5eff3f8fa74714fe10986be094915c800.tar.bz2
use document fragments to grow repeaters
- unless we are repeating OPTION elements, buffer new nodes in document fragment and append them to the DOM in one go at the end - for OPTION elements we have to keep on using the old way because of how option widget communicates with select widget this should be change, but that change is out of scope of this CL - modify jqLite to support wrapping of document fragments - fix jqLite documentation typo This change unintentionally avoids the following webkit bug that that affects repeater growth: https://bugs.webkit.org/show_bug.cgi?id=57059 However the following bug affecting shrining of repeaters is still unresolved https://bugs.webkit.org/show_bug.cgi?id=57061
Diffstat (limited to 'src')
-rw-r--r--src/jqLite.js5
-rw-r--r--src/widgets.js19
2 files changed, 19 insertions, 5 deletions
diff --git a/src/jqLite.js b/src/jqLite.js
index 8554263a..78fc1655 100644
--- a/src/jqLite.js
+++ b/src/jqLite.js
@@ -66,7 +66,7 @@ function JQLite(element) {
div.innerHTML = '<div>&nbsp;</div>' + element; // IE insanity to make NoScope elements work!
div.removeChild(div.firstChild); // remove the superfluous div
JQLiteAddNodes(this, div.childNodes);
- this.remove(); // detach the elements form the temporary DOM div.
+ this.remove(); // detach the elements from the temporary DOM div.
} else {
JQLiteAddNodes(this, element);
}
@@ -136,8 +136,7 @@ function JQLiteAddNodes(root, elements) {
? elements
: [ elements ];
for(var i=0; i < elements.length; i++) {
- if (elements[i].nodeType != 11)
- root.push(elements[i]);
+ root.push(elements[i]);
}
}
}
diff --git a/src/widgets.js b/src/widgets.js
index a7d59289..2b44fccc 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -914,6 +914,8 @@ angularWidget('@ng:repeat', function(expression, element){
lastIterElement = iterStartElement,
collection = this.$tryEval(rhs, iterStartElement),
collectionLength = size(collection, true),
+ fragment = (element[0].nodeName != 'OPTION') ? document.createDocumentFragment() : null,
+ addFragment,
childScope,
key;
@@ -938,13 +940,26 @@ angularWidget('@ng:repeat', function(expression, element){
children.push(childScope);
linker(childScope, function(clone){
clone.attr('ng:repeat-index', index);
- lastIterElement.after(clone);
- lastIterElement = clone;
+
+ if (fragment) {
+ fragment.appendChild(clone[0]);
+ addFragment = true;
+ } else {
+ //temporarily preserve old way for option element
+ lastIterElement.after(clone);
+ lastIterElement = clone;
+ }
});
}
index ++;
}
}
+
+ //attach new nodes buffered in doc fragment
+ if (addFragment) {
+ lastIterElement.after(jqLite(fragment));
+ }
+
// shrink children
while(children.length > index) {
children.pop().$element.remove();