Created
May 4, 2010 20:33
-
-
Save rwaldron/389933 to your computer and use it in GitHub Desktop.
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
(function ($) { | |
$.fn.pollute = function (pollution) { | |
// first we extend the pollution object to the window, nice! | |
$.extend(window, pollution); | |
// make sure we're really nasty, and pollute all the elements as well. | |
return this.each(function () { | |
for ( var junk in pollution ) { | |
if ( typeof pollution[junk] === 'object' ) { | |
$(this).pollute(pollution[junk]); | |
return; | |
} | |
$.extend(this, pollution); | |
} | |
}); | |
} | |
})(jQuery); | |
//Usage | |
$(document).pollute({ | |
foo: 'bar', | |
more: { | |
crap: 'baz', | |
yuck: 'junk' | |
}, | |
badass: window | |
}); | |
// Automatically adds foo to the global scope! | |
// As an added bonus the junk gets put on EVERY MATCHED ELEMENT in the collection as well! | |
// Yippee!! |
@brennannovak i just realized you jar-jar-jinxed this
heeehe
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lol!