You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2007/01/25 06:07:58 UTC

svn commit: r499676 - in /incubator/xap/trunk/codebase/src/xap: Xap.js taghandling/PluginDocumentHandler.js util/Debug.js

Author: mturyn
Date: Wed Jan 24 22:07:58 2007
New Revision: 499676

URL: http://svn.apache.org/viewvc?view=rev&rev=499676
Log:
Fixed debugging:
1.) Made sure <script/> element is actually appended under the <HEAD/> element, or at worst the <HTML/> element, so that no matter from where the import is called, it will work, which means that...
2.)...we can load each script from Xap.require() instead of adding it to a list of classes to be debug-loaded later, which allows us to have...
3.)...removed the need for a Xap.loadDebuggables() call in the html---if there's a valid debug_config with _debugAll!=false or a non-null _debugList, we're set.

Re.1:  Formerly, we were using document.write to write script tag information, which meant that we could easily write it somewhere illegal.

Modified:
    incubator/xap/trunk/codebase/src/xap/Xap.js
    incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js
    incubator/xap/trunk/codebase/src/xap/util/Debug.js

Modified: incubator/xap/trunk/codebase/src/xap/Xap.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/Xap.js?view=diff&rev=499676&r1=499675&r2=499676
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/Xap.js (original)
+++ incubator/xap/trunk/codebase/src/xap/Xap.js Wed Jan 24 22:07:58 2007
@@ -179,7 +179,9 @@
 	try {
 		dojo.require.apply(dojo, arguments);
 		if (needToDebugLoad && !alreadyDebugLoaded ) {
-			xap.util.Debug.addDebuggables(toLoad);
+			// This adds a <script/> element to
+			// the <head/> contents:
+			xap.util.Debug._loadDebuggable(toLoad);
 			Xap.ourDebugLoadClasses[toLoad] = true;
 		}
 		result = true;

Modified: incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js?view=diff&rev=499676&r1=499675&r2=499676
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js (original)
+++ incubator/xap/trunk/codebase/src/xap/taghandling/PluginDocumentHandler.js Wed Jan 24 22:07:58 2007
@@ -139,15 +139,11 @@
 	//now that we have the name of the bridge class, make a
 	//new one, loading its class first if necessary:
 	try {
-		// Note:  we could actually just do the require() without seeing
-		// if it's there yet, as require() checks first; still, it seems
-		// better (and less dependent on another behaviour working
-		// correctly) to check first:
+		// Even if the dojo.require() has already done this,
+		// do this here in case we need to do a debug-load---
+		// dojo won't load it again if it has before:
+		Xap.require( bridgeClassName );
 		handlerConstructor =  Xap.resolveConstructor(bridgeClassName ) ;
-		if (typeof handlerConstructor == "undefined" ){
-			Xap.require( bridgeClassName );
-			handlerConstructor =  Xap.resolveConstructor(bridgeClassName ) ;
-		}
 	} catch (classNotLoadableException){
 		xap.taghandling.PluginDocumentHandler.s_log.exception( "Exception while loading '" 	
 										+ bridgeClassName +"'"	

Modified: incubator/xap/trunk/codebase/src/xap/util/Debug.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/util/Debug.js?view=diff&rev=499676&r1=499675&r2=499676
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/util/Debug.js (original)
+++ incubator/xap/trunk/codebase/src/xap/util/Debug.js Wed Jan 24 22:07:58 2007
@@ -66,7 +66,7 @@
 		return;
 	}else{ 
 		// Just in case we got a string:
-		if (!(arguments[0] instanceof String) ){
+		if ( (typeof arguments[0]) != "string" ){
 			for (var nom in arguments[0]){
 				xap.util.Debug._loadDebuggable(nom) ;
 			}
@@ -121,7 +121,7 @@
 	arr.shift() ;
 	path = prePath +"/"+ arr.join("/") +".js" ;
 
-	Xap.logString += ";"+ path;
+//	Xap.logString += ";"+ path;
 	xap.util.Debug.importFile(path) ;
 }
 
@@ -133,7 +133,7 @@
 	xap.util.Debug._debugLoad = tf ;
 } 
 
-xap.util.Debug.HEAD=null ;
+xap.util.Debug.SCRIPT_PARENT=null ;
 xap.util.Debug.importFile = function( path ) {
 
 
@@ -144,31 +144,32 @@
 		return;
 	}
 	xap.util.Debug.s_pathCache[path] = true;
-//	var scriptString = "<script language=\"JavaScript\" " +
-//		"type=\"text/javascript\" src=\"" + path + "\"></script>";
-//	document.write( scriptString );
-	if( !xap.util.Debug.HEAD ){
-		var allHeads = document.getElementsByTagName("HEAD") ;
-		if(allHeads && allHeads.length>1){
+
+
+	if( !xap.util.Debug.SCRIPT_PARENT ){
+		var allScripts = document.getElementsByTagName("SCRIPT") ;
+		if(allScripts && allScripts.length>1){
 		// should only have one....
-			xap.util.Debug.HEAD	= allHeads[0] ;
+			xap.util.Debug.SCRIPT_PARENT	= allScripts[0].parentNode ;
 		}
 	}
-	if( !xap.util.Debug.HEAD ){
+	var element = document.createElement("SCRIPT") ;
+	element.type="text/javascript" ;
+	element.language="JavaScript" ;
+	element.src = path ;
+	
+	var theParent = xap.util.Debug.SCRIPT_PARENT ;	
+
+	if( !xap.util.Debug.SCRIPT_PARENT ){
 		// Faute de mieux---but often won't work once the body elements's
 		// in place:
-		var scriptString = "<script language=\"JavaScript\" " +
-			"type=\"text/javascript\" src=\"" + path + "\"></script>";
-		document.write( scriptString );	
-	
-	} else {
-		var element = document.createElement("SCRIPT") ;
-		element.type="text/javascript" ;
-		element.language="JavaScript" ;
-		element.src = path ;
-		alert(path) ;
-		xap.util.Debug.HEAD.appendChild( element) ;
-	}
+		var allHTMLs = document.getElementsByTagName("HTML") ;
+		// TODO:  Find out why sometimes there is more than 
+		// one---why?  In any event, the last one is the one we
+		// want:		
+		theParent = allHTMLs.pop() ;		
+	} 
+	theParent.appendChild(element) ;	
 }
 
 xap.util.Debug.s_pathCache = null;