[Pkg-javascript-commits] [dojo] 23/32: Refs #12342. Backport [30011] and [30096] to 1.6 to support IE 9/10. !strict

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 17:39:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag 1.6.2
in repository dojo.

commit 07b0f83eaec541177497aad22ef2bd0499d06403
Author: Douglas Hays <doughays at dojotoolkit.org>
Date:   Sat Jan 12 12:04:25 2013 +0000

    Refs #12342.  Backport [30011] and [30096] to 1.6 to support IE 9/10. !strict
    
    git-svn-id: http://svn.dojotoolkit.org/src/branches/1.6/dojo@30338 560b804f-0ae3-0310-86f3-f6aa0a117693
---
 _base/html.js         | 59 ++++++++++++++++++++++++---------------------------
 tests/_base/html.html | 23 +++++++++++---------
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/_base/html.js b/_base/html.js
index a00c1a0..328ce62 100644
--- a/_base/html.js
+++ b/_base/html.js
@@ -91,14 +91,6 @@ if(dojo.isIE){
 //>>excludeEnd("webkitMobile");
 	var byId = d.byId;
 
-	var _destroyContainer = null,
-		_destroyDoc;
-	//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-	d.addOnWindowUnload(function(){
-		_destroyContainer = null; //prevent IE leak
-	});
-	//>>excludeEnd("webkitMobile");
-
 /*=====
 	dojo._destroyElement = function(node){
 		// summary:
@@ -106,6 +98,15 @@ if(dojo.isIE){
 		// 		in 2.0
 	}
 =====*/
+	function _destroy(/*DomNode*/ node, /*DomNode*/ parent){
+		if(node.firstChild){
+			_empty(node);
+		}
+		if(parent){
+			parent.removeChild(node);
+		}
+	}
+
 	dojo._destroyElement = dojo.destroy = function(/*String|DomNode*/node){
 		//	summary:
 		//		Removes a node from its parent, clobbering it and all of its
@@ -127,19 +128,8 @@ if(dojo.isIE){
 		//	|	dojo.query(".someNode").forEach(dojo.destroy);
 
 		node = byId(node);
-		try{
-			var doc = node.ownerDocument;
-			// cannot use _destroyContainer.ownerDocument since this can throw an exception on IE
-			if(!_destroyContainer || _destroyDoc != doc){
-				_destroyContainer = doc.createElement("div");
-				_destroyDoc = doc;
-			}
-			_destroyContainer.appendChild(node.parentNode ? node.parentNode.removeChild(node) : node);
-			// NOTE: see http://trac.dojotoolkit.org/ticket/2931. This may be a bug and not a feature
-			_destroyContainer.innerHTML = "";
-		}catch(e){
-			/* squelch */
-		}
+		if(!node){ return; }
+		_destroy(node, node.parentNode);
 	};
 
 	dojo.isDescendant = function(/*DomNode|String*/node, /*DomNode|String*/ancestor){
@@ -854,7 +844,7 @@ if(dojo.isIE){
 		}
 		// On Opera, offsetLeft includes the parent's border
 		//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-		if(d.isOpera){ pe.l += be.l; pe.t += be.t; };
+		if(d.isOpera){ pe.l += be.l; pe.t += be.t; }
 		//>>excludeEnd("webkitMobile");
 		return {
 			l: pe.l,
@@ -1167,7 +1157,7 @@ if(dojo.isIE){
 			ret = node.getBoundingClientRect();
 			ret = { x: ret.left, y: ret.top, w: ret.right - ret.left, h: ret.bottom - ret.top };
 		//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-			if(d.isIE){
+			if(d.isIE < 9){
 				// On IE there's a 2px offset that we need to adjust for, see _getIeDocumentElementOffset()
 				var offset = d._getIeDocumentElementOffset();
 
@@ -1578,19 +1568,26 @@ if(dojo.isIE){
 	}
 	=====*/
 
-	d.empty =
+	var _empty =
 		//>>excludeStart("webkitMobile", kwArgs.webkitMobile);
-		d.isIE ?  function(node){
-			node = byId(node);
-			for(var c; c = node.lastChild;){ // intentional assignment
-				d.destroy(c);
+		d.isIE ? function(/*DomNode*/ node){
+			try{
+				node.innerHTML = ""; // really fast when it works
+			}catch(e){ // IE can generate Unknown Error
+				for(var c; c = node.lastChild;){ // intentional assignment
+					_destroy(c, node); // destroy is better than removeChild so TABLE elements are removed in proper order
+				}
 			}
 		} :
 		//>>excludeEnd("webkitMobile");
-		function(node){
-			byId(node).innerHTML = "";
+		function(/*DomNode*/ node){
+			node.innerHTML = "";
 		};
 
+	d.empty = function(node){
+		_empty(byId(node));
+	};
+
 	/*=====
 	dojo._toDom = function(frag, doc){
 			//	summary:
@@ -1675,7 +1672,7 @@ if(dojo.isIE){
 
 		// return multiple nodes as a document fragment
 		df = doc.createDocumentFragment();
-		while(fc = master.firstChild){ // intentional assignment
+		while((fc = master.firstChild)){ // intentional assignment
 			df.appendChild(fc);
 		}
 		return df; // DOMNode
diff --git a/tests/_base/html.html b/tests/_base/html.html
index 7352947..f96989c 100644
--- a/tests/_base/html.html
+++ b/tests/_base/html.html
@@ -467,13 +467,15 @@
 							return def;
 						},
 						function attr_reconnect(t){
-							var input = document.createElement("input");
+							var input = document.createElement("input"),
+								input2 = document.createElement("input");
 							var ctr = 0;
 							dojo.attr(input, "type", "text");
 							dojo.attr(input, "onfocus", function(e){ ctr++; });
 							dojo.attr(input, "onfocus", function(e){ ctr++; });
 							dojo.attr(input, "onfocus", function(e){ ctr++; });
 							dojo.body().appendChild(input);
+							dojo.body().appendChild(input2);
 							if(!dojo.isIE || dojo.isIE > 7){
 								// IE6/7 treats type="text" as missing, even if it was
 								// explicitly specified
@@ -482,15 +484,16 @@
 							doh.is(0, ctr);
 							var def = new doh.Deferred();
 							input.focus();
-							setTimeout(function(){
-								doh.is(1, ctr);
-								input.blur();
-								input.focus();
-								setTimeout(function(){
-									doh.is(2, ctr);
-									def.callback(true);
-								}, 10);
-							}, 10);
+							setTimeout(def.getTestErrback(function(){
+								doh.is(1, ctr, "onfocus ctr == 1");
+								input2.focus();
+								setTimeout(def.getTestErrback(function(){
+									input.focus();
+									setTimeout(def.getTestCallback(function(){
+										doh.is(2, ctr, "onfocus ctr == 2");
+									}), 10);
+								}), 10);
+							}), 10);
 							return def;
 						},
 						function attrSpecials(){

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/dojo.git



More information about the Pkg-javascript-commits mailing list