diff --git a/library/Zend/View/Helper/HeadLink.php b/library/Zend/View/Helper/HeadLink.php index f1079f99d2c..b04b3a2e7fc 100644 --- a/library/Zend/View/Helper/HeadLink.php +++ b/library/Zend/View/Helper/HeadLink.php @@ -289,7 +289,11 @@ public function itemToString(stdClass $item) && !empty($attributes['conditionalStylesheet']) && is_string($attributes['conditionalStylesheet'])) { - $link = ''; + // inner wrap with comment end and start if !IE + if (str_replace(' ', '', $attributes['conditionalStylesheet']) === '!IE') { + $link = '' . $link . ''; } return $link; diff --git a/library/Zend/View/Helper/HeadMeta.php b/library/Zend/View/Helper/HeadMeta.php index 9927d46bc15..59dc5da3271 100644 --- a/library/Zend/View/Helper/HeadMeta.php +++ b/library/Zend/View/Helper/HeadMeta.php @@ -269,6 +269,10 @@ public function itemToString(stdClass $item) && !empty($item->modifiers['conditional']) && is_string($item->modifiers['conditional'])) { + // inner wrap with comment end and start if !IE + if (str_replace(' ', '', $item->modifiers['conditional']) === '!IE') { + $meta = '' . $meta . ''; } diff --git a/library/Zend/View/Helper/HeadScript.php b/library/Zend/View/Helper/HeadScript.php index 30609be1d36..d432a1ef0b6 100644 --- a/library/Zend/View/Helper/HeadScript.php +++ b/library/Zend/View/Helper/HeadScript.php @@ -408,6 +408,10 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd) && !empty($item->attributes['conditional']) && is_string($item->attributes['conditional'])) { + // inner wrap with comment end and start if !IE + if (str_replace(' ', '', $item->attributes['conditional']) === '!IE') { + $html = '' . $html . ''; } else { $html = $indent . $html; diff --git a/library/Zend/View/Helper/HeadStyle.php b/library/Zend/View/Helper/HeadStyle.php index 66e2103e259..45df6e6546f 100644 --- a/library/Zend/View/Helper/HeadStyle.php +++ b/library/Zend/View/Helper/HeadStyle.php @@ -333,7 +333,11 @@ public function itemToString(stdClass $item, $indent) . ''; if (null == $escapeStart && null == $escapeEnd) { - $html = ''; + // inner wrap with comment end and start if !IE + if (str_replace(' ', '', $item->attributes['conditional']) === '!IE') { + $html = '' . $html . ''; } return $html; diff --git a/tests/ZendTest/View/Helper/HeadLinkTest.php b/tests/ZendTest/View/Helper/HeadLinkTest.php index ac49718d937..cae38d11038 100644 --- a/tests/ZendTest/View/Helper/HeadLinkTest.php +++ b/tests/ZendTest/View/Helper/HeadLinkTest.php @@ -277,6 +277,32 @@ public function testConditionalStylesheetCreationOccursWhenRequested() $this->assertContains('', $string); } + public function testConditionalStylesheetCreationNoIE() + { + $this->helper->setStylesheet('/styles.css', 'screen', '!IE'); + $item = $this->helper->getValue(); + $this->assertObjectHasAttribute('conditionalStylesheet', $item); + $this->assertEquals('!IE', $item->conditionalStylesheet); + + $string = $this->helper->toString(); + $this->assertContains('/styles.css', $string); + $this->assertContains('<', $string); + $this->assertContains('', $string); + } + + public function testConditionalStylesheetCreationNoIEWidthSpaces() + { + $this->helper->setStylesheet('/styles.css', 'screen', '! IE'); + $item = $this->helper->getValue(); + $this->assertObjectHasAttribute('conditionalStylesheet', $item); + $this->assertEquals('! IE', $item->conditionalStylesheet); + + $string = $this->helper->toString(); + $this->assertContains('/styles.css', $string); + $this->assertContains('<', $string); + $this->assertContains('', $string); + } + public function testSettingAlternateWithTooFewArgsRaisesException() { try { diff --git a/tests/ZendTest/View/Helper/HeadMetaTest.php b/tests/ZendTest/View/Helper/HeadMetaTest.php index b78eeda5f54..bc60c45582a 100644 --- a/tests/ZendTest/View/Helper/HeadMetaTest.php +++ b/tests/ZendTest/View/Helper/HeadMetaTest.php @@ -529,5 +529,20 @@ public function testConditional() $this->assertRegExp("|^$|", $html); } + + public function testConditionalNoIE() + { + $html = $this->helper->appendHttpEquiv('foo', 'bar', array('conditional' => '!IE'))->toString(); + + $this->assertContains('<', $html); + $this->assertContains('', $html); + } + public function testConditionalNoIEWidthSpace() + { + $html = $this->helper->appendHttpEquiv('foo', 'bar', array('conditional' => '! IE'))->toString(); + + $this->assertContains('<', $html); + $this->assertContains('', $html); + } } diff --git a/tests/ZendTest/View/Helper/HeadScriptTest.php b/tests/ZendTest/View/Helper/HeadScriptTest.php index c70cfa02d41..cd627c139ca 100644 --- a/tests/ZendTest/View/Helper/HeadScriptTest.php +++ b/tests/ZendTest/View/Helper/HeadScriptTest.php @@ -379,6 +379,30 @@ public function testConditionalScriptWidthIndentation() $this->assertContains(' <', $test); + $this->assertContains('', $test); + } + + public function testConditionalScriptNoIEWidthSpace() + { + $this->helper->setAllowArbitraryAttributes(true); + $this->helper->appendFile( + '/js/foo.js', 'text/javascript', array('conditional' => '! IE') + ); + $test = $this->helper->toString(); + + $this->assertContains('<', $test); + $this->assertContains('', $test); + } + /** * @issue ZF-5435 */ diff --git a/tests/ZendTest/View/Helper/HeadStyleTest.php b/tests/ZendTest/View/Helper/HeadStyleTest.php index d707c1aea60..02e2f0112c5 100644 --- a/tests/ZendTest/View/Helper/HeadStyleTest.php +++ b/tests/ZendTest/View/Helper/HeadStyleTest.php @@ -362,6 +362,28 @@ public function testConditionalScript() $this->assertContains('<', $test); + $this->assertContains('', $test); + } + + public function testConditionalScriptNoIEWidthSpace() + { + $this->helper->appendStyle(' +a { + display: none; +}', array('media' => 'screen,projection', 'conditional' => '! IE')); + $test = $this->helper->toString(); + $this->assertContains('<', $test); + $this->assertContains('', $test); + } + /** * @issue ZF-5435 */