adium 2759:81552ae2f111: So, apparently DocumentFragment does ju...
commits at adium.im
commits at adium.im
Wed Oct 21 17:44:10 UTC 2009
details: http://hg.adium.im/adium/rev/81552ae2f111
revision: 2759:81552ae2f111
author: Stephen Holt <sholt at adium.im>
date: Wed Oct 21 13:43:51 2009 -0400
So, apparently DocumentFragment does just fine with querySelector*. Save some time recalculating that.
diffs (32 lines):
diff -r 1baad7856ddd -r 81552ae2f111 Plugins/WebKit Message View/Template.html
--- a/Plugins/WebKit Message View/Template.html Wed Oct 21 10:29:33 2009 -0400
+++ b/Plugins/WebKit Message View/Template.html Wed Oct 21 13:43:51 2009 -0400
@@ -21,7 +21,7 @@
// (ex. a long twitter timeline)
function CoalescedHTML() {
var self = this;
- this.fragment = document.createElement("div");
+ this.fragment = document.createDocumentFragment();
this.timeoutID = 0;
this.coalesceRounds = 0;
this.isCoalescing = false;
@@ -32,17 +32,11 @@
if(insert)
insert.parentNode.removeChild(insert);
- // wrap the elements into a documentFragment for fast insertion
- var documentFragment = document.createDocumentFragment();
- while(self.fragment.hasChildNodes()) {
- documentFragment.appendChild(self.fragment.firstChild);
- }
-
- document.getElementById("Chat").appendChild(documentFragment);
+ // insert the documentFragment into the live DOM
+ document.getElementById("Chat").appendChild(self.fragment);
alignChat(self.shouldScroll);
// reset state to empty/non-coalescing
- documentFragment = null;
self.shouldScroll = false;
self.isCoalescing = false;
self.coalesceRounds = 0;
More information about the commits
mailing list