diff --git a/framework/yii/helpers/base/Html.php b/framework/yii/helpers/base/Html.php
index 8d1a384..d8cf675 100644
--- a/framework/yii/helpers/base/Html.php
+++ b/framework/yii/helpers/base/Html.php
@@ -21,11 +21,6 @@ use yii\base\Model;
class Html
{
/**
- * @var boolean whether to close void (empty) elements. Defaults to true.
- * @see voidElements
- */
- public static $closeVoidElements = true;
- /**
* @var array list of void elements (element name => 1)
* @see closeVoidElements
* @see http://www.w3.org/TR/html-markup/syntax.html#void-element
@@ -49,12 +44,6 @@ class Html
'wbr' => 1,
);
/**
- * @var boolean whether to show the values of boolean attributes in element tags.
- * If false, only the attribute names will be generated.
- * @see booleanAttributes
- */
- public static $showBooleanAttributeValues = true;
- /**
* @var array list of boolean attributes. The presence of a boolean attribute on
* an element represents the true value, and the absence of the attribute represents the false value.
* @see showBooleanAttributeValues
@@ -165,11 +154,10 @@ class Html
*/
public static function tag($name, $content = '', $options = array())
{
- $html = '<' . $name . static::renderTagAttributes($options);
if (isset(static::$voidElements[strtolower($name)])) {
- return $html . (static::$closeVoidElements ? ' />' : '>');
+ return static::beginTag($name, $options);
} else {
- return $html . ">$content$name>";
+ return static::beginTag($name, $options) . $content . static::endTag($name);
}
}
@@ -185,7 +173,7 @@ class Html
*/
public static function beginTag($name, $options = array())
{
- return '<' . $name . static::renderTagAttributes($options) . '>';
+ return "<$name" . static::renderTagAttributes($options) . '>';
}
/**
@@ -201,16 +189,6 @@ class Html
}
/**
- * Encloses the given content within a CDATA tag.
- * @param string $content the content to be enclosed within the CDATA tag
- * @return string the CDATA tag with the enclosed content.
- */
- public static function cdata($content)
- {
- return '';
- }
-
- /**
* Generates a style tag.
* @param string $content the style content
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
@@ -221,10 +199,7 @@ class Html
*/
public static function style($content, $options = array())
{
- if (!isset($options['type'])) {
- $options['type'] = 'text/css';
- }
- return static::tag('style', "/**/", $options);
+ return static::tag('style', $content, $options);
}
/**
@@ -238,10 +213,7 @@ class Html
*/
public static function script($content, $options = array())
{
- if (!isset($options['type'])) {
- $options['type'] = 'text/javascript';
- }
- return static::tag('script', "/**/", $options);
+ return static::tag('script', $content, $options);
}
/**
@@ -256,7 +228,6 @@ class Html
public static function cssFile($url, $options = array())
{
$options['rel'] = 'stylesheet';
- $options['type'] = 'text/css';
$options['href'] = static::url($url);
return static::tag('link', '', $options);
}
@@ -272,7 +243,6 @@ class Html
*/
public static function jsFile($url, $options = array())
{
- $options['type'] = 'text/javascript';
$options['src'] = static::url($url);
return static::tag('script', '', $options);
}
@@ -313,7 +283,10 @@ class Html
// we use hidden fields to add them back
foreach (explode('&', substr($action, $pos + 1)) as $pair) {
if (($pos1 = strpos($pair, '=')) !== false) {
- $hiddenInputs[] = static::hiddenInput(urldecode(substr($pair, 0, $pos1)), urldecode(substr($pair, $pos1 + 1)));
+ $hiddenInputs[] = static::hiddenInput(
+ urldecode(substr($pair, 0, $pos1)),
+ urldecode(substr($pair, $pos1 + 1))
+ );
} else {
$hiddenInputs[] = static::hiddenInput(urldecode($pair), '');
}
@@ -395,7 +368,7 @@ class Html
if (!isset($options['alt'])) {
$options['alt'] = '';
}
- return static::tag('img', null, $options);
+ return static::tag('img', '', $options);
}
/**
@@ -424,14 +397,10 @@ class Html
* @param array $options the tag options in terms of name-value pairs. These will be rendered as
* the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
* If a value is null, the corresponding attribute will not be rendered.
- * If the options does not contain "type", a "type" attribute with value "button" will be rendered.
* @return string the generated button tag
*/
public static function button($content = 'Button', $options = array())
{
- if (!isset($options['type'])) {
- $options['type'] = 'button';
- }
return static::tag('button', $content, $options);
}
@@ -482,7 +451,7 @@ class Html
$options['type'] = $type;
$options['name'] = $name;
$options['value'] = $value;
- return static::tag('input', null, $options);
+ return static::tag('input', '', $options);
}
/**
@@ -497,7 +466,7 @@ class Html
{
$options['type'] = 'button';
$options['value'] = $label;
- return static::tag('input', null, $options);
+ return static::tag('input', '', $options);
}
/**
@@ -512,7 +481,7 @@ class Html
{
$options['type'] = 'submit';
$options['value'] = $label;
- return static::tag('input', null, $options);
+ return static::tag('input', '', $options);
}
/**
@@ -526,7 +495,7 @@ class Html
{
$options['type'] = 'reset';
$options['value'] = $label;
- return static::tag('input', null, $options);
+ return static::tag('input', '', $options);
}
/**
@@ -1315,7 +1284,7 @@ class Html
foreach ($attributes as $name => $value) {
if (isset(static::$booleanAttributes[strtolower($name)])) {
if ($value || strcasecmp($name, $value) === 0) {
- $html .= static::$showBooleanAttributeValues ? " $name=\"$name\"" : " $name";
+ $html .= " $name";
}
} elseif ($value !== null) {
$html .= " $name=\"" . static::encode($value) . '"';
diff --git a/tests/unit/framework/base/FormatterTest.php b/tests/unit/framework/base/FormatterTest.php
index e9a909f..87a41c9 100644
--- a/tests/unit/framework/base/FormatterTest.php
+++ b/tests/unit/framework/base/FormatterTest.php
@@ -96,7 +96,7 @@ class FormatterTest extends TestCase
public function testAsImage()
{
$value = 'http://sample.com/img.jpg';
- $this->assertSame("", $this->formatter->asImage($value));
+ $this->assertSame("", $this->formatter->asImage($value));
}
public function testAsBoolean()
diff --git a/tests/unit/framework/helpers/HtmlTest.php b/tests/unit/framework/helpers/HtmlTest.php
index 28cc86f..14f7fc3 100644
--- a/tests/unit/framework/helpers/HtmlTest.php
+++ b/tests/unit/framework/helpers/HtmlTest.php
@@ -44,24 +44,11 @@ class HtmlTest extends TestCase
public function testTag()
{
- $this->assertEquals('
', Html::tag('br'));
- $this->assertEquals('', Html::tag('span'));
- $this->assertEquals('