From d4848c0379e5cfa3932310b4a9e4c284ea652a79 Mon Sep 17 00:00:00 2001 From: impinball Date: Thu, 9 Jul 2015 03:34:41 -0400 Subject: [PATCH] Remove trailing whitespace --- docs/mithril.render.md | 2 +- mithril.d.ts | 2 +- modulator-test.html | 110 ++++++++++++++++++++--------------------- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/docs/mithril.render.md b/docs/mithril.render.md index 0b4c6beb..39b0a808 100644 --- a/docs/mithril.render.md +++ b/docs/mithril.render.md @@ -122,4 +122,4 @@ where: - **Boolean forceRecreation** - If set to true, rendering a new virtual tree will completely overwrite an existing one without attempting to diff against it \ No newline at end of file + If set to true, rendering a new virtual tree will completely overwrite an existing one without attempting to diff against it diff --git a/mithril.d.ts b/mithril.d.ts index c9763a96..ba006753 100644 --- a/mithril.d.ts +++ b/mithril.d.ts @@ -17,7 +17,7 @@ declare module _mithril { mount(rootElement: Node): T; component(component: MithrilComponent, ...args: Array): MithrilComponent - + trust(html: string): string; render(rootElement: Element|HTMLDocument): void; diff --git a/modulator-test.html b/modulator-test.html index 761573ac..a4349ceb 100644 --- a/modulator-test.html +++ b/modulator-test.html @@ -7,10 +7,10 @@ var mod = ( function initModulator(){ var Map = shim; var WeakMap = shim; } - + // Garbage collection flag mod.cleanup = true; - + // Registry of instantiation contexts var contexts = new WeakMap(); // All automated counts @@ -20,36 +20,36 @@ var mod = ( function initModulator(){ var snapRedraw = m.redraw; var redraw; var forced; - + for( var key in m.redraw ){ queueRedraw[ key ] = snapRedraw[ key ] = m.redraw[ key ]; } - + return function pause(){ m.redraw = queueRedraw; - + setTimeout( function unpause(){ m.redraw = snapRedraw; - + if( redraw ) m.redraw( forced ); - + redraw = forced = false; } ); } - + function queueRedraw( force ){ redraw = true; - + if( force ) forced = true; } }() ); var unique = {}; - + // Clear counts at the begninning of every redraw m.module( document.createElement( 'x' ), { view : counts.clear.bind( counts ) } ); - + // Shorthand for a component which will always return the same instance mod.unique = function( component ){ return mod( component, unique, unique ); @@ -58,80 +58,80 @@ var mod = ( function initModulator(){ mod.global = function( x ){ return mod( x, unique ); }; - + // Extend controllers with extra utility functions mod.extend = true; - + return mod; - + function mod( component, context, key ){ // Stand in for m.module, eg mod( document.body, component, context ); if( component instanceof HTMLElement ){ // Stand in for m.route if( !component.controller && !component.view ){ var routes = {}; - + for( var route in context ){ routes[ route ].controller = mod.unique( { controller : context[ route ].controller || noop } ).bind(); } - + return m.route( component, routes ); } - + return m.module( component, mod.apply( undefined, [].slice.call( arguments, 1 ) ) )(); } - + var components = register( contexts, context || unique, WeakMap ); var keys = register( components, component, WeakMap ); - + return function identify( key ){ var count = key === undefined && register( counts, keys, m.prop.bind( undefined, 0 ) ); // eg. ctrl.mod( profile ).mapWith( users(), 'username' ); apply.mapWith = function( collection ){ var path = [].slice.call( arguments, 1 ); - + return Object.keys( collection ).map( function getItemIdentifier( index ){ var key; - + if( path.length ){ key = path.reduce( function getKeyValue( source, segment ){ var node = source[ segment ]; - + if( node instanceof Function ) node = node.call( source ); - + return node; }, collection[ index ] ); } else { key = index; } - + return identify( key )( collection[ index ] ); } ); }; - + return apply; - + function apply(){ var args = [].slice.call( arguments ); var view; - + if( count ){ key = count( count() + 1 ); } - + var ctrl = register( keys, key, function newController(){ pauseRedraw(); - + var controller = component.controller || noop; var instance = new ( controller.bind.apply( controller, [ controller ].concat( args ) ) )(); - + if( mod.cleanup ){ garbageCollect( instance ); } - + if( mod.extend ){ // Shorthand for instantiatin sub-modules instance.mod = function( component, key ){ @@ -145,14 +145,14 @@ var mod = ( function initModulator(){ instance.refresh = function(){ args = [].slice.call( arguments ); ctrl = register( keys, key, newController, true ); - + return m.redraw; }; } - + return instance; } ); - + // Return the controller instance if the component is view-less. if( component.view ){ if( args.length ){ @@ -161,31 +161,31 @@ var mod = ( function initModulator(){ else { view = component.view( ctrl ); } - + if( view instanceof Object ){ view.ctrl = ctrl; } - + return view; } - + return ctrl; } }( key ); - + // Performance: when controllers succesfully unload, destroy their associated maps function garbageCollect( ctrl ){ onunload = ctrl.onunload; - + if( onunload === teardown ){ return; } - + ctrl.onunload = teardown; - + function teardown( e ){ var go = true; - + if( onunload ){ onunload( { preventDefault : function(){ @@ -193,39 +193,39 @@ var mod = ( function initModulator(){ } } ); } - + if( go ){ contexts.delete( context ); } } } } - + // Convenience map method: retrieve key from map. If it's not registered, set it first with Constructor. function register( map, key, Constructor, force ){ return !force && map.has( key ) ? map.get( key ) : map.set( key, new Constructor() ).get( key ); } - + function shim(){ var keys = []; var values = []; var map = { get : function( key ){ var index = keys.indexOf( key ); - + return values[ index ]; }, has : function( key ){ var index = keys.indexOf( key ); - + return index > -1; }, set : function( key, value ){ var index = map.has( key ) ? keys.indexOf( key ) : keys.length; - + keys[ index ] = key; values[ index ] = value; - + return map; }, clear : function(){ @@ -234,21 +234,21 @@ var mod = ( function initModulator(){ }, delete : function( key ){ var index = keys.indexOf( key ); - + if( index > -1 ){ keys.splice( index, 1 ); values.splice( index, 1 ); - + return true; } - + return false; } }; - + return map; } - + function noop(){} }() ); @@ -271,4 +271,4 @@ b.view = function(ctrl, count) { return m("li", count) } -m.module(document.body, a) \ No newline at end of file +m.module(document.body, a)