penguin/AstroJS

Javascript framework for my blog

commit 6c9011f92c1d953cd6b8ccf87c020f8b1205fb3f

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-05-09T07:51:00Z
subjectShould also aware of the loaded classes
commit 6c9011f92c1d953cd6b8ccf87c020f8b1205fb3f
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-05-09T07:51:00Z

    Should also aware of the loaded classes
---
 botanjs/src/System/Net/ClassLoader.js | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/botanjs/src/System/Net/ClassLoader.js b/botanjs/src/System/Net/ClassLoader.js
index 16adf6e..d81175b 100644
--- a/botanjs/src/System/Net/ClassLoader.js
+++ b/botanjs/src/System/Net/ClassLoader.js
@@ -9,6 +9,8 @@
 	/** @type {Dandelion} */
 	var Dand                         = __import( "Dandelion" );
 
+	var LoadedClasses = {};
+
 	var loadFile = function ( sapi, request, mode )
 	{
 		var head = Dand.tag( "head" )[0];
@@ -59,13 +61,13 @@
 			for( var i in classes )
 			{
 				var c = classes[i];
-				if( excludes.indexOf( c ) == -1 )
+				if( ~excludes.indexOf( c ) || LoadedClasses[ c ] )
 				{
-					needed.push( c );
+					handler( c );
 				}
 				else
 				{
-					handler( c );
+					needed.push( c );
 				}
 			}
 
@@ -84,7 +86,15 @@
 			);
 
 			BotanJS.addEventListener( "NS_INIT", onLoad );
-			BotanJS.addEventListener( "NS_EXPORT", onLoad );
+
+			BotanJS.addEventListener( "NS_EXPORT", function( e )
+			{
+				if( e.data.name )
+				{
+					LoadedClasses[ e.data.name ] = 1;
+				}
+				onLoad( e );
+			} );
 		};
 	};