Merge pull request #19 from WinterSilence/patch-2

Fix value of attribute aria-current in LinkPager
This commit is contained in:
simialbi 2021-11-30 11:43:16 +01:00 committed by GitHub
commit 9be83b526a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -5,6 +5,7 @@ Yii Framework 2 bootstrap5 extension Change Log
----------------------- -----------------------
- Enh #18: Add rangeInput(), colorInput() and switch mode to checkbox() in class ActiveField (WinterSilence) - Enh #18: Add rangeInput(), colorInput() and switch mode to checkbox() in class ActiveField (WinterSilence)
- Bug #19: Fix value of attribute "aria-current" in LinkPager::renderPageButton() (WinterSilence)
2.0.2 October 21, 2021 2.0.2 October 21, 2021

View File

@ -285,13 +285,13 @@ class LinkPager extends Widget
{ {
$options = $this->linkContainerOptions; $options = $this->linkContainerOptions;
$linkWrapTag = ArrayHelper::remove($options, 'tag', 'li'); $linkWrapTag = ArrayHelper::remove($options, 'tag', 'li');
Html::addCssClass($options, empty($class) ? $this->pageCssClass : $class); Html::addCssClass($options, $class ?: $this->pageCssClass);
$linkOptions = $this->linkOptions; $linkOptions = $this->linkOptions;
$linkOptions['data-page'] = $page; $linkOptions['data-page'] = $page;
if ($active) { if ($active) {
$options['aria'] = ['current' => 'true']; $options['aria'] = ['current' => 'page'];
Html::addCssClass($options, $this->activePageCssClass); Html::addCssClass($options, $this->activePageCssClass);
} }
if ($disabled) { if ($disabled) {

View File

@ -70,12 +70,12 @@ class LinkPagerTest extends TestCase
'pagination' => $pagination, 'pagination' => $pagination,
'disableCurrentPageButton' => false, 'disableCurrentPageButton' => false,
]); ]);
$this->assertContains('<li class="page-item active" aria-current="true"><a class="page-link" href="/?r=test&amp;page=6" data-page="5">6</a></li>', $output); $this->assertContains('<li class="page-item active" aria-current="page"><a class="page-link" href="/?r=test&amp;page=6" data-page="5">6</a></li>', $output);
$output = LinkPager::widget([ $output = LinkPager::widget([
'pagination' => $pagination, 'pagination' => $pagination,
'disableCurrentPageButton' => true, 'disableCurrentPageButton' => true,
]); ]);
$this->assertContains('<li class="page-item active disabled" aria-current="true"><a class="page-link" href="/?r=test&amp;page=6" data-page="5" tabindex="-1">6</a></li>', $output); $this->assertContains('<li class="page-item active disabled" aria-current="page"><a class="page-link" href="/?r=test&amp;page=6" data-page="5" tabindex="-1">6</a></li>', $output);
} }
public function testOptionsWithTagOption() public function testOptionsWithTagOption()
@ -105,7 +105,7 @@ class LinkPagerTest extends TestCase
$output $output
); );
$this->assertContains( $this->assertContains(
'<div class="my-class page-item active" aria-current="true"><a class="page-link" href="/?r=test&amp;page=2" data-page="1">2</a></div>', '<div class="my-class page-item active" aria-current="page"><a class="page-link" href="/?r=test&amp;page=2" data-page="1">2</a></div>',
$output $output
); );
} }