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
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 * Custom elements hooks.
 */

use Drupal\Component\Render\MarkupInterface;
use Drupal\Core\Render\Markup;
use Drupal\custom_elements\CustomElement;
use Drupal\Core\Entity\EntityInterface;
@@ -49,6 +50,10 @@ function template_preprocess_custom_element(&$variables) {
        $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['tag_prefix'] = $custom_element->getTagPrefix() ? $custom_element->getTagPrefix() . '-' : '';
+2 −2
Original line number Diff line number Diff line
@@ -258,9 +258,9 @@ EOF;
      ->generate($paragraph, 'full');
    $markup = $this->renderCustomElement($custom_element);
    $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;
    Assert::assertXmlStringEqualsXmlString($this->trim($expected_markup), $this->trim($markup));
    Assert::assertEquals($this->trim($expected_markup), $this->trim($markup));
  }

  /**
+1 −1
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ EOF;
      ->generate($paragraph, 'full');
    $markup = $this->renderCustomElement($custom_element);
    $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;
    Assert::assertEquals($this->trim($expected_markup), $this->trim($markup));
  }