Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Title: Disallow <div>, only allow <drupal-entity> » [PP-1] Disallow <div>, only allow <drupal-entity>
Status: Active » Postponed

Turns out I can't fix this due to a bug elsewhere — see #2547085-12: Remove the <drupal-entity>/<div> placeholder instead of embedding the entity as a child:

I ran into this bug in yet another way: via the test coverage while working on #2628358: Disallow <div>, only allow <drupal-entity>:

// Test that tag of container element is not replaced when it's not
    // 'drupal-entity'.
    $content = '<not-drupal-entity data-entity-type="node" data-entity-id="' . $this->node->id() . '" data-view-mode="teaser">this placeholder should not be rendered.</not-drupal-entity>';
    $settings = array();
    $settings['type'] = 'page';
    $settings['title'] = 'test entity embed with entity-id and view-mode';
    $settings['body'] = array(array('value' => $content,

It says "test that anything else than is NOT replaced" … but then it tests that it DOES get replaced! Yet it also tests that </not-drupal-entity> still exists… And both tests pass! That is not logically possible!

Except this bug makes it possible: because we never ever replace the original DOM node, we also cannot reliably test some cases, because the original HTML is never actually replaced.

This is therefore postponed on that issue.

Wim Leers’s picture

Title: [PP-1] Disallow <div>, only allow <drupal-entity> » [PP-2] Disallow <div>, only allow <drupal-entity>
Related issues: +#2628358: Disallow <div>, only allow <drupal-entity>, +#2602316: Allow any HTML as content for replaceNodeContent

Turns out I can't fix even that due to a bug further down — see #2547085-16: Remove the <drupal-entity>/<div> placeholder instead of embedding the entity as a child:

But… HAH! That won't actually work, because embed's replaceNodeContent() is broken: see #2602316: Allow any HTML as content for replaceNodeContent. It will only actually import the first DOM node. And the first DOM node when rendering an article template happens to be… a text DOM node with a newline in it. The second DOM node is the <article class="type-node" …> HTML that we expect.

So, with the above, tests actually fail for both patches because embed is broken…

Now working on #2602316: Allow any HTML as content for replaceNodeContent.

slashrsm’s picture

Status: Postponed » Active
Issue tags: +Zurich media sprint 2015

Embed patch was committed.

Wim Leers’s picture

Title: [PP-2] Disallow <div>, only allow <drupal-entity> » Disallow <div>, only allow <drupal-entity>

And the other patch was also committed. Yay :)

Patch forthcoming.

Wim Leers’s picture

Status: Active » Needs review
FileSize
20.12 KB
Wim Leers’s picture

Fix one of the related issues: I accidentally referenced this issue, which is nonsensical of course.

dawehner’s picture

I'm wondering whether we could at least provide a helper update function which takes a string and replaced the old way with the new way, so that people can write some custom update functions if they like?

Wim Leers’s picture

slashrsm’s picture

Status: Needs review » Fixed

Good stuff! Committed. Thanks.

  • slashrsm committed b3e00da on 8.x-1.x authored by Wim Leers
    Issue #2628358 by Wim Leers: Disallow <div>, only allow <drupal-entity>
    
Wim Leers’s picture

Published the CR.

Wim Leers’s picture

And yay, one child issue of #2628168: Clean up Entity Embed's data model completed!

  • Devin Carlson committed b25bd6e on 7.x-3.x
    Issue #2628358 by Wim Leers: Disallow <div>, only allow <drupal-entity>
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.