Reputation: 5793
I'm checking this particular syntax with new wordpress 4.7:
<!--[if gte IE 9]><!-->
<script type="text/javascript">
(function() {
var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');
request = true;
b[c] = b[c].replace( rcs, ' ' );
// The customizer requires postMessage and CORS (if the site is cross domain)
b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
}());
</script>
<!--<![endif]-->
I'm a little bit confused and wondering if I'm missing something. Doesn't it supposed to be:
<!--[if gte IE 9]>
<script type="text/javascript">
(function() {
var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');
request = true;
b[c] = b[c].replace( rcs, ' ' );
// The customizer requires postMessage and CORS (if the site is cross domain)
b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
}());
</script>
<![endif]-->
What's the logic behind using an empty comment in the first line and using endif in another comment tag ?
Upvotes: 2
Views: 156
Reputation: 943163
It is supposed to hide the content from IE8 and lower.
If it used the second style of code you suggested then it would hide the content from all browsers which did not support conditional comments too. That is, it would make the code available to IE9 and nothing else.
Remember that a comment stretches between <!--
and -->
, not between <!--
and >
. There are no empty comments there. See also: the syntax highlighting Stackoverflow added.
Upvotes: 1