From 6c9011f92c1d953cd6b8ccf87c020f8b1205fb3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Mon, 9 May 2016 15:51:00 +0800 Subject: [PATCH] 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 ); + } ); }; };