-
-
Save carldanley/28e40cc32c60909fb947 to your computer and use it in GitHub Desktop.
A simple example of the facade pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a simple facade that masks the various browser-specific methods | |
function addEvent( element, event, callback ) { | |
if( window.addEventListener ) { | |
element.addEventListener( event, callback, false ); | |
} else if( document.attachEvent ) { | |
element.attachEvent( 'on' + event, callback ); | |
} else { | |
element[ 'on' + event ] = callback; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment