adium 2773:eadbff5014e6: Simpler is better, and avoid looping th...

commits at adium.im commits at adium.im
Sat Oct 24 20:03:58 UTC 2009


details:	http://hg.adium.im/adium/rev/eadbff5014e6
revision:	2773:eadbff5014e6
author:		Stephen Holt <sholt at adium.im>
date:		Sat Oct 24 16:03:35 2009 -0400

Simpler is better, and avoid looping though elements when we don't have to.

diffs (22 lines):

diff -r d17d8a241b66 -r eadbff5014e6 Plugins/WebKit Message View/Template.html
--- a/Plugins/WebKit Message View/Template.html	Sat Oct 24 14:38:12 2009 -0400
+++ b/Plugins/WebKit Message View/Template.html	Sat Oct 24 16:03:35 2009 -0400
@@ -50,15 +50,9 @@
 			// creates and returns a new documentFragment, containing all content nodes
 			// which can be inserted as a single node.
 			function createHTMLNode(html) {
-				var newMessage = document.createElement("div");
-				var documentFragment = document.createDocumentFragment();
-				newMessage.innerHTML = html;
-				
-				while(newMessage.hasChildNodes()) {
-					documentFragment.appendChild(newMessage.firstChild);
-				}
-				
-				return documentFragment;
+				var range = document.createRange();
+				range.selectNode(document.getElementById("Chat"));
+				return range.createContextualFragment(html);
 			}
 			
 			// removes first insert node from the internal fragment.




More information about the commits mailing list