Skip to content

Commit

Permalink
Issue magento#10645 - Allow BEM class via attribute tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Danilo Argentiero authored and amol2jcommerce committed Mar 17, 2019
1 parent 71e61a7 commit ab7aee9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/View/Page/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public function addRss($title, $href)
*/
public function addBodyClass($className)
{
$className = preg_replace('#[^a-z0-9]+#', '-', strtolower($className));
$className = preg_replace('#[^a-z0-9-]+#', '-', strtolower($className));
$bodyClasses = $this->getElementAttribute(self::ELEMENT_TYPE_BODY, self::BODY_ATTRIBUTE_CLASS);
$bodyClasses = $bodyClasses ? explode(' ', $bodyClasses) : [];
$bodyClasses[] = $className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public function testProcess()
->method('getPageConfigStructure')
->willReturn($structureMock);

$bodyClasses = ['class_1', 'class_2'];
$bodyClasses = ['class_1', 'class--2'];
$structureMock->expects($this->once())
->method('getBodyClasses')
->will($this->returnValue($bodyClasses));
$this->pageConfigMock->expects($this->exactly(2))
->method('addBodyClass')
->withConsecutive(['class_1'], ['class_2']);
->withConsecutive(['class_1'], ['class--2']);

$this->assertEquals(
$this->bodyGenerator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testSetElementAttribute()
public function testSetBodyClass()
{
$class1 = 'class_1';
$class2 = 'class_2';
$class2 = 'class--2';
$expected = [$class1, $class2];
$this->structure->setBodyClass($class1);
$this->structure->setBodyClass($class2);
Expand Down

0 comments on commit ab7aee9

Please sign in to comment.