Skip to content

Instantly share code, notes, and snippets.

@spite
Last active August 29, 2015 14:15
Show Gist options
  • Save spite/3b8f3a095048122ef19f to your computer and use it in GitHub Desktop.
Save spite/3b8f3a095048122ef19f to your computer and use it in GitHub Desktop.
Makes creating canvas, audio, video and other HTML elements less verbose
( function() {
function sugarifyNew( id ) {
var name = id + '';
var fnName = name.charAt( 0 ).toUpperCase() + name.substr( 1 );
window[ fnName ] = function() {
return document.createElement( id );
}
}
sugarifyNew( 'canvas' );
sugarifyNew( 'video' );
} )();
var canvas = new Canvas(),
video = new Video();
@spite
Copy link
Author

spite commented Feb 17, 2015

Removed Audio because there's already a constructor for that. (duh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment