Permalink
Browse files

Preventing `\template\Helper` from being too smart about attribute mi…

…nimization.
  • Loading branch information...
1 parent 0334f33 commit ffe62c6fa54e04bde2c9547cdf1d597e5a5dcf30 @nateabele nateabele committed Aug 11, 2010
Showing with 18 additions and 1 deletion.
  1. +1 −1 libraries/lithium/template/Helper.php
  2. +17 −0 libraries/lithium/tests/cases/template/HelperTest.php
View
2 libraries/lithium/template/Helper.php
@@ -137,7 +137,7 @@ protected function _formatAttr($key, $value, array $options = array()) {
$options += $defaults;
if (in_array($key, $this->_minimized)) {
- $isMini = ($value == 1 || $value === true || $value === 'true' || $value == $key);
+ $isMini = ($value == 1 || $value === true || $value == $key);
if (!($value = $isMini ? $key : $value)) {
return null;
}
View
17 libraries/lithium/tests/cases/template/HelperTest.php
@@ -88,6 +88,23 @@ public function testAttributes() {
$this->assertEqual($expected, $result);
}
+ public function testAttributeMinimization() {
+ $attributes = array('selected' => 1);
+ $expected = ' selected="selected"';
+ $result = $this->helper->testAttributes($attributes);
+ $this->assertEqual($expected, $result);
+
+ $attributes = array('selected' => true);
+ $expected = ' selected="selected"';
+ $result = $this->helper->testAttributes($attributes);
+ $this->assertEqual($expected, $result);
+
+ $attributes = array('selected' => 'true');
+ $expected = ' selected="true"';
+ $result = $this->helper->testAttributes($attributes);
+ $this->assertEqual($expected, $result);
+ }
+
public function testRender() {
$params = array(
'context' => new MockRenderer(),

0 comments on commit ffe62c6

Please sign in to comment.