From 320e53e7103511bd25bbff3b6441fd7560905ed3 Mon Sep 17 00:00:00 2001 From: Danilo Argentiero Date: Fri, 25 Aug 2017 10:28:49 +0200 Subject: [PATCH 1/2] Issue #10645 - Allow BEM class via attribute tag. --- lib/internal/Magento/Framework/View/Page/Config.php | 2 +- .../View/Test/Unit/Page/Config/Generator/BodyTest.php | 4 ++-- .../Framework/View/Test/Unit/Page/Config/StructureTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Page/Config.php b/lib/internal/Magento/Framework/View/Page/Config.php index 248841e47499d..a33b3c61d545c 100644 --- a/lib/internal/Magento/Framework/View/Page/Config.php +++ b/lib/internal/Magento/Framework/View/Page/Config.php @@ -463,7 +463,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; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/BodyTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/BodyTest.php index 0f59c302f943f..ed926afa00856 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/BodyTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/Generator/BodyTest.php @@ -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, diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/StructureTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/StructureTest.php index ed15a356cc4c7..d2eba5d2fa1b3 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/StructureTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/Config/StructureTest.php @@ -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); From f30af4178df04d05fe33ab4c19e08f45f7b13f47 Mon Sep 17 00:00:00 2001 From: Danilo Argentiero Date: Fri, 25 Aug 2017 14:55:17 +0200 Subject: [PATCH 2/2] Issue #10645 Allow underscore charachter for BEM class via attribute tag --- lib/internal/Magento/Framework/View/Page/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/View/Page/Config.php b/lib/internal/Magento/Framework/View/Page/Config.php index a33b3c61d545c..a5bbefb33008e 100644 --- a/lib/internal/Magento/Framework/View/Page/Config.php +++ b/lib/internal/Magento/Framework/View/Page/Config.php @@ -463,7 +463,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;