Last active
December 13, 2015 16:58
-
-
Save MoOx/4943645 to your computer and use it in GitHub Desktop.
My nano modernizr
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
<html class="no-js no-touch"> | |
<script>(function(docEl) { | |
docEl.className = docEl.className.replace(/\bno-js\b/, 'js'); | |
if ('ontouchstart' in docEl) { docEl.className = docEl.className.replace(/\bno-touch\b/, 'touch'); } | |
})(document.documentElement);</script> | |
<!-- <link stylsheet /> | |
<body> | |
<script> --> | |
</html> |
<html class="no-jstuff">
breaks
Over particulier :p
Mais dans ce cas, au lieu de faire 2 captures tu peux simplement faire appel à \b
pour borner tes mots :
docEl.className = docEl.className.replace(/\bno-js\b/, 'js');
if ('ontouchstart' in docEl) { docEl.className = docEl.className.replace(/\bno-touch\b/, 'touch');}
Bien vu. Updated with your enhancement.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pourquoi utiliser des regexp ici lorsque lla manipulation de chaine reste simple ?