Fix typo preventing canonicalization.
[xhtml-compiler.git] / XHTMLCompiler / DOMFilter / IEConditionalComments.php
blob83c2dbeecde797a7c48d0c8cc196757d9ef7baf2
1 <?php
3 /**
4 * Enables Internet Explorer style conditional comments to survive XML
5 * parsing by implementing a custom xc:ie-condition attribute to attach
6 * to elements.
7 */
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');
21 if ($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);