Created
December 29, 2010 15:45
-
-
Save bebraw/758651 to your computer and use it in GitHub Desktop.
Shorter version of http://www.hagenburger.net/BLOG/Simple-HTML5-Fix-for-IE.html .
This file contains hidden or 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
| // original | |
| for(e,l='article aside footer header nav section time'.split(' ');e=l.pop();document.createElement(e)) | |
| // original + moved pop | |
| for(l='article aside footer header nav section time'.split(' ');;document.createElement(l.pop())) | |
| // mine (not tested! might need some braces...) | |
| // v1 (no globals) | |
| var l=['article','aside','footer','header','nav','section','time'];for(var i in l)document.createElement(l[i]) | |
| // v2 (globals) | |
| l=['article','aside','footer','header','nav','section','time'];for(i in l)document.createElement(l[i]) |
Author
I think the last version is about as compact as I can get. Saves a few chars. Not sure if it's worth it, though...
For v1 l will also be in the global scope. For me, the new scope created by for is worth it :)
Btw. the split version is even a bit smaller, especially if you add more HTML5 elements.
Author
True. Just figured out you can probably refactor "e" out of the original version. Just pop at createElement.
You may want to avoid endless loops.
Author
Oh. Gotcha! Man, I need to test these things... :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
inreturns the index, so it would result in 0, 1, 2, …