[richfaces-svn-commits] JBoss Rich Faces SVN: r2251 - trunk/framework/impl/src/main/javascript/prototype.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Aug 14 10:40:12 EDT 2007


Author: nbelaevski
Date: 2007-08-14 10:40:12 -0400 (Tue, 14 Aug 2007)
New Revision: 2251

Modified:
   trunk/framework/impl/src/main/javascript/prototype/patches.js
Log:
- Node class containing node type constants added
- Element.isUninitialized() method updated to handle Node with nodeType == Node.ELEMENT_NODE only in order to skip document, window, etc.

Modified: trunk/framework/impl/src/main/javascript/prototype/patches.js
===================================================================
--- trunk/framework/impl/src/main/javascript/prototype/patches.js	2007-08-14 14:38:09 UTC (rev 2250)
+++ trunk/framework/impl/src/main/javascript/prototype/patches.js	2007-08-14 14:40:12 UTC (rev 2251)
@@ -29,32 +29,50 @@
 	return supposedParent == node;
 };
 
+if (typeof Node == "undefined") {
+	Node = {
+		ELEMENT_NODE: 1,
+  		ATTRIBUTE_NODE: 2,
+  		TEXT_NODE: 3,
+  		CDATA_SECTION_NODE: 4,
+  		ENTITY_REFERENCE_NODE: 5,
+  		ENTITY_NODE: 6,
+  		PROCESSING_INSTRUCTION_NODE: 7,
+  		COMMENT_NODE: 8,
+  		DOCUMENT_NODE: 9,
+  		DOCUMENT_TYPE_NODE: 10,
+  		DOCUMENT_FRAGMENT_NODE: 11,
+  		NOTATION_NODE: 12
+	};
+};
+
 Element.isUninitialized = function(element) {
 	if (element) {
-		if (!element.parentNode || element.document && element.document.readyState == "uninitialized") {
-			return true;
+		if (element.nodeType == Node.ELEMENT_NODE) {
+		
+			if (!element.parentNode || element.document && element.document.readyState == "uninitialized") {
+				return true;
+			}
+		
+			return false;
 		}
-	
-		return false;
 	}
 };
 
 Event.unloadElementsCache = function() {
     if (!Event.observers) return;
-    var compact = false;
+    //refer to window.unload handling conditions in prototype script
+    if (!Prototype.Browser.IE) return;
+    
     var observers = Event.observers;
     for (var i = 0, length = observers.length; i < length; i++) {
     	var observer = observers[i];
     	var elt = observer[0];
     	
     	if (Element.isUninitialized(elt)) {
-	    	compact = true;
 	    	Event.stopObserving.apply(Event, observer);
-	    	observers[i] = null;
+	    	observers.splice(i--, 1);
+	    	length--;
     	}
     }
-    
-    if (compact) {
-    	Event.observers = observers.compact();
-    }
 };
\ No newline at end of file




More information about the richfaces-svn-commits mailing list