Commit 2aa87a94 authored by Ben Mullins's avatar Ben Mullins
Browse files

Issue #3268318 by lauriii, Wim Leers, tim.plunkett: [drupalMedia] <a> with GHS...

Issue #3268318 by lauriii, Wim Leers, tim.plunkett: [drupalMedia] <a> with GHS allowed attributes downcast wraps data-caption with <a>
parent 1e0f5410
Loading
Loading
Loading
Loading
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ function upcastMediaLink() {

        // There's an <drupal-media> inside an <a> element - we consume it so it
        // won't be picked up by the Link plugin.
        const consumableAttributes = { attributes: ['href'] };
        const consumableAttributes = { attributes: ['href'], name: true };

        // Consume the `href` attribute so the default one will not convert it to
        // $text attribute.
+4 −10
Original line number Diff line number Diff line
@@ -791,16 +791,6 @@ public function testLinkability(bool $unrestricted) {
    // linking media.
    $this->assertNotEmpty($xpath->query('//a[@href="http://linking-embedded-media.com"]/drupal-media[@data-caption="baz"]'));

    // Remove caption from media for now to avoid incompatibility issues in GHS
    // linked media integration.
    // @todo remove this step after
    //   https://www.drupal.org/project/drupal/issues/3268318 has been resolved.
    $this->assertNotEmpty($drupalmedia = $assert_session->waitForElementVisible('css', '.ck-content .ck-widget.drupal-media'));
    $drupalmedia->click();
    $this->assertVisibleBalloon('.ck-toolbar[aria-label="Drupal Media toolbar"]');
    $this->getBalloonButton('Toggle caption off')->click();
    $this->assertTrue($assert_session->waitForElementRemoved('css', '.ck-content .ck-widget.drupal-media figcaption'));

    // Add `class="trusted"` to the link.
    $this->assertEmpty($xpath->query('//a[@href="http://linking-embedded-media.com" and @class="trusted"]'));
    $this->pressEditorButton('Source');
@@ -857,6 +847,10 @@ public function testLinkability(bool $unrestricted) {
    $assert_session->elementNotExists('css', '.ck-content a');
    $assert_session->elementExists('css', '.ck-content .drupal-media.ck-widget > div[aria-label] > article > div > img[src*="image-test.png"]');

    // Ensure that figcaption exists.
    // @see https://www.drupal.org/project/drupal/issues/3268318
    $assert_session->elementExists('css', '.ck-content .drupal-media.ck-widget > figcaption');

    // Assert the "dataDowncast" HTML after making changes.
    $xpath = new \DOMXPath($this->getEditorDataAsDom());
    $this->assertNotEmpty($xpath->query('//drupal-media'));