Skip to content

Commit a76f249

Browse files
ENGCOM-6937: [Layout] Adding 'article' as an additional supported layout tag #26904
- Merge Pull Request #26904 from eduard13/magento2:container-article-tag - Merged commits: 1. 1d2dd67 2. da37605
2 parents cde4f67 + da37605 commit a76f249

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

dev/tests/integration/testsuite/Magento/Framework/View/LayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function testAddContainerInvalidHtmlTag()
274274
{
275275
$msg = 'Html tag "span" is forbidden for usage in containers. ' .
276276
'Consider to use one of the allowed: aside, dd, div, dl, fieldset, main, nav, ' .
277-
'header, footer, ol, p, section, table, tfoot, ul.';
277+
'header, footer, ol, p, section, table, tfoot, ul, article.';
278278
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
279279
$this->expectExceptionMessage($msg);
280280
$this->_layout->addContainer('container', 'Container', ['htmlTag' => 'span']);

lib/internal/Magento/Framework/View/Layout/Generator/Container.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\View\Layout;
99

10+
/**
11+
* Layout Container Class
12+
*/
1013
class Container implements Layout\GeneratorInterface
1114
{
1215
/**#@+
@@ -39,10 +42,11 @@ class Container implements Layout\GeneratorInterface
3942
'table',
4043
'tfoot',
4144
'ul',
45+
'article',
4246
];
4347

4448
/**
45-
* {@inheritdoc}
49+
* @inheritdoc
4650
*
4751
* @return string
4852
*/
@@ -95,8 +99,12 @@ public function generateContainer(
9599
}
96100

97101
/**
102+
* Validate container options
103+
*
98104
* @param array $options
105+
*
99106
* @return void
107+
*
100108
* @throws \Magento\Framework\Exception\LocalizedException
101109
*/
102110
protected function validateOptions($options)

lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,26 @@ public function processDataProvider()
138138
['first_container', Container::CONTAINER_OPT_HTML_ID, 'dd_id'],
139139
],
140140
'setAttributeCalls' => 3,
141+
],
142+
'Article as allowed container tag' => [
143+
'structureElements' => [
144+
'first_container' => [
145+
'container',
146+
[
147+
'attributes' => [
148+
Container::CONTAINER_OPT_HTML_TAG => 'article',
149+
Container::CONTAINER_OPT_HTML_CLASS => 'article_class',
150+
Container::CONTAINER_OPT_HTML_ID => 'article_id',
151+
]
152+
],
153+
],
154+
],
155+
'setAttributeData' => [
156+
['first_container', Container::CONTAINER_OPT_HTML_TAG, 'article'],
157+
['first_container', Container::CONTAINER_OPT_HTML_CLASS, 'article_class'],
158+
['first_container', Container::CONTAINER_OPT_HTML_ID, 'article_id'],
159+
],
160+
'setAttributeCalls' => 3,
141161
]
142162
];
143163
}

0 commit comments

Comments
 (0)