4 * Enables Internet Explorer style conditional comments to survive XML
5 * parsing by implementing a custom xc:ie-condition attribute to attach
8 class XHTMLCompiler_DOMFilter_IEConditionalComments
extends XHTMLCompiler_DOMFilter
11 protected $name = 'IEConditionalComments';
12 protected $xcAttr = array('ie-condition');
14 public function process(DOMDocument
$dom, $page, $manager) {
16 $nodes = $this->query( "//*[@xc:ie-condition]" );
18 if ($nodes) $manager->addDependency(__FILE__
);
19 foreach ($nodes as $node) {
20 $condition = $this->confiscateAttr($node, $this->ns
, 'ie-condition');
22 $sxml = simplexml_import_dom($node);
23 $code = $sxml->asXml();
24 $comment = "[if $condition]>$code<![endif]";
25 $parent = $node->parentNode
;
26 $parent->replaceChild($dom->createComment($comment), $node);