Skip to content
Snippets Groups Projects
Commit 7fb11d69 authored by Petar Bašić's avatar Petar Bašić Committed by Volodymyr Mostepaniuk
Browse files

Issue #3324583 by petar_basic, useernamee, mostepaniukvm, fago: Attributes...

Issue #3324583 by petar_basic, useernamee, mostepaniukvm, fago: Attributes with html markup get html stripped
parent db35f791
No related branches found
No related tags found
1 merge request!19Issue #3324583: Attributes with html markup get html stripped
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Custom elements hooks. * Custom elements hooks.
*/ */
use Drupal\Component\Render\MarkupInterface;
use Drupal\Core\Render\Markup; use Drupal\Core\Render\Markup;
use Drupal\custom_elements\CustomElement; use Drupal\custom_elements\CustomElement;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
...@@ -49,6 +50,10 @@ function template_preprocess_custom_element(&$variables) { ...@@ -49,6 +50,10 @@ function template_preprocess_custom_element(&$variables) {
$key = ":$key"; $key = ":$key";
} }
} }
// Attributes with html markup get html stripped, so we convert to string.
if ($value instanceof MarkupInterface) {
$value = (string) $value;
}
$variables['attributes'][$key] = $value; $variables['attributes'][$key] = $value;
} }
$variables['tag_prefix'] = $custom_element->getTagPrefix() ? $custom_element->getTagPrefix() . '-' : ''; $variables['tag_prefix'] = $custom_element->getTagPrefix() ? $custom_element->getTagPrefix() . '-' : '';
... ...
......
...@@ -258,9 +258,9 @@ EOF; ...@@ -258,9 +258,9 @@ EOF;
->generate($paragraph, 'full'); ->generate($paragraph, 'full');
$markup = $this->renderCustomElement($custom_element); $markup = $this->renderCustomElement($custom_element);
$expected_markup = <<<EOF $expected_markup = <<<EOF
<pg-image caption="&lt;strong&gt;Custom Elements&lt;/strong&gt; &lt;p&gt;image&lt;/p&gt; description" copyright="custom elements copyright" src="{$this->image->uri->url}" type="image" view-mode="full"/> <pg-image type="image" view-mode="full" src="{$this->image->uri->url}" copyright="custom elements copyright" caption="&lt;p&gt;&amp;lt;strong&amp;gt;Custom Elements&amp;lt;/strong&amp;gt; &amp;lt;p&amp;gt;image&amp;lt;/p&amp;gt; description&lt;/p&gt;"></pg-image>
EOF; EOF;
Assert::assertXmlStringEqualsXmlString($this->trim($expected_markup), $this->trim($markup)); Assert::assertEquals($this->trim($expected_markup), $this->trim($markup));
} }
/** /**
... ...
......
...@@ -257,7 +257,7 @@ EOF; ...@@ -257,7 +257,7 @@ EOF;
->generate($paragraph, 'full'); ->generate($paragraph, 'full');
$markup = $this->renderCustomElement($custom_element); $markup = $this->renderCustomElement($custom_element);
$expected_markup = <<<EOF $expected_markup = <<<EOF
<pg-image type="image" view-mode="full" src="{$this->image->uri->url}" copyright="custom elements copyright" caption="&lt;strong&gt;Custom Elements&lt;/strong&gt; &lt;p&gt;image&lt;/p&gt; description"></pg-image> <pg-image type="image" view-mode="full" src="{$this->image->uri->url}" copyright="custom elements copyright" caption="&lt;p&gt;&amp;lt;strong&amp;gt;Custom Elements&amp;lt;/strong&amp;gt; &amp;lt;p&amp;gt;image&amp;lt;/p&amp;gt; description&lt;/p&gt;"></pg-image>
EOF; EOF;
Assert::assertEquals($this->trim($expected_markup), $this->trim($markup)); Assert::assertEquals($this->trim($expected_markup), $this->trim($markup));
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment