IE Comment Resolving

In the modus operandi IE conditional comments (<!--[if …]>…<!endif]-->) are not handled specifically. They are treated like normal HTML comments. HTML code included therein intended for Internet Explorer browsers is sent to any client, even to non-IE browsers.

It is rather inconvenient to manually process this IE-specific HTML code, i.e. evaluate XPaths or do XSL transformations, as it is all comments. Furthermore, FIT automatically rewrites URLs – but only on element nodes. URLs in conditional comments will stay untouched.

Conditional comment resolving can help with that. You can enable it in your configuration:

<config>
  <acceleration>
    <ie-comment-resolving/>
  </acceleration>
</config>

It depends on the client detected by the Delivery Context what the result will look like. Internet Explorers supporting conditional comments will get the HTML content intended for them. That HTML will then be parsed and processed as usual. URLs contained therein will be rewritten. For all other browsers the text filter will completely remove all conditional comments when resolving is enabled.

Malformed conditional comments won’t be touched.

Limitations

Note, that only downlevel-hidden comments (<!--[if …]>…<!endif]--> or <!--[if …]><!-->…<!--<![endif]-->) are supported. Downlevel-revealed conditional comments (<![if !IE]>…<![endif]>) are invalid markup and are therefore not supported.

FIT supports conditional comment expressions with the features IE, MobileIE, true and false. Other features like WindowsEdition are considered invalid.

Nested comments are not specifically handled and may be wrongly resolved.

The conditional comment resolver does not take the HTML context into account and therefore even resolves comments within HTML elements like xmp, textarea, script, style and within attributes.

Example

Consider the following HTML snippet:

<link rel="stylesheet" href="styles.css">
<!--[if lt IE 9 ]><link rel="stylesheet" href="legacy-ie.css"><![endif]-->

In the modus operandi FIT will rewrite the URL styles.css and leave the conditional comment alone. The included URL is not rewritten:

<link rel="stylesheet" href="http://fitserver.example.com/site-prefix/styles.css">
<!--[if lt IE 9 ]><link rel="stylesheet" href="legacy-ie.css"><![endif]-->

If ie-comment-resolving is enabled in config.xml the result depends on the client detected by the Delivery Context. If it is an Internet Explorer 8 or older (lt IE 9) the result will be:

<link rel="stylesheet" href="http://fitserver.example.com/site-prefix/styles.css">
<link rel="stylesheet" href="http://fitserver.example.com/site-prefix/legacy-ie.css">

A more recent IE or any other browser will get the following code:

<link rel="stylesheet" href="http://fitserver.example.com/site-prefix/styles.css">