With MetaDOM style I wrote a little function to add runtime external scripts, this time compatible with all modern browser ;) This function is similar with Python import syntax, using From to specify a folder, or why not an uri, Import to add one or more script and finally an optional And method to call a callback on scripts loaded. Here You can view an example From("jsFolder") . Import("MyScript", "MyOhterScript") Seems cool? The first goal is to add dynamically one or more script in a simple and fast way. These script will be available on onload event if they're imported before this event. These scripts should be available on DOMContentLoaded too, but to be sure these script will be available You could add a callback using last method. From("jsFolder") . Import("MyScript", "MyOhterScript") . And(DoStuff) DoStuff is a function that do something with loaded scripts. What else You should do? You could load different ext...
There are way too many ways to stub functions or methods, but at the end of the day all we want to know is always the same: has that function been invoked ? has that function received the expected context ? which argument has been passed to that function ? what was the output of the function ? Update thanks to @bga_ hint about the output property in after notification, it made perfect sense The Concept For fun and no profit I have created a prototype which aim is to bring a DOM like interface to any sort of function or method in order to monitor its lifecycle: the "before" event, able to preventDefault() and avoid the original function call at all the "after" event, in order to understand if the function did those expected changes to the environment or to a generic input object, or simply to analyze the output of the previous call the "error" event, in case we want to be notified if something went wrong during function execution the "handlerer...
Comments
Post a Comment