Commit 81b6738a authored by Alexander Makarov's avatar Alexander Makarov Committed by GitHub

Fixes #162: Fixed `yii\bootstrap\Nav` not taking explicit `active` into...

Fixes #162: Fixed `yii\bootstrap\Nav` not taking explicit `active` into account when `activateItems` is off
parent 55d6d7f2
...@@ -10,6 +10,7 @@ Yii Framework 2 bootstrap extension Change Log ...@@ -10,6 +10,7 @@ Yii Framework 2 bootstrap extension Change Log
- Bug #137: Remove `role="navbar"` from `yii\bootstrap\NavBar` according to new aria specification (tino415) - Bug #137: Remove `role="navbar"` from `yii\bootstrap\NavBar` according to new aria specification (tino415)
- Enh #113: Allow URLs instead of content for Tab Widget Dropdown items (Okeanos) - Enh #113: Allow URLs instead of content for Tab Widget Dropdown items (Okeanos)
- Bug #143: Fixed `yii\bootstrap\Nav` to use tags according to bootstrap docs (PowerGamer1) - Bug #143: Fixed `yii\bootstrap\Nav` to use tags according to bootstrap docs (PowerGamer1)
- Bug #162: Fixed `yii\bootstrap\Nav` not taking explicit `active` into account when `activateItems` is off (samdark)
2.0.6 March 17, 2016 2.0.6 March 17, 2016
-------------------- --------------------
......
...@@ -199,7 +199,7 @@ class Nav extends Widget ...@@ -199,7 +199,7 @@ class Nav extends Widget
} }
} }
if ($this->activateItems && $active) { if ($active) {
Html::addCssClass($options, 'active'); Html::addCssClass($options, 'active');
} }
......
...@@ -115,6 +115,35 @@ EXPECTED; ...@@ -115,6 +115,35 @@ EXPECTED;
<li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Dropdown1 <span class="caret"></span></a><ul id="w1" class="dropdown-menu"><li class="dropdown-header">Page2</li> <li class="dropdown"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Dropdown1 <span class="caret"></span></a><ul id="w1" class="dropdown-menu"><li class="dropdown-header">Page2</li>
<li class="dropdown-header">Page3</li></ul></li> <li class="dropdown-header">Page3</li></ul></li>
<li><a href="#">Page4</a></li></ul> <li><a href="#">Page4</a></li></ul>
EXPECTED;
$this->assertEqualsWithoutLE($expected, $out);
}
/**
* @see https://github.com/yiisoft/yii2-bootstrap/issues/162
*/
public function testExplicitActive()
{
Nav::$counter = 0;
$out = Nav::widget([
'activateItems' => false,
'items' => [
[
'label' => 'Item1',
//'url' => ['some/route1'],
'active' => true,
],
[
'label' => 'Item2',
//'url' => ['some/route2'],
],
],
]);
$expected = <<<EXPECTED
<ul id="w0" class="nav"><li class="active"><a href="#">Item1</a></li>
<li><a href="#">Item2</a></li></ul>
EXPECTED; EXPECTED;
$this->assertEqualsWithoutLE($expected, $out); $this->assertEqualsWithoutLE($expected, $out);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment