Only strings with single top level element (root) works correctly:
<div>content</div>Simple string
Following strings didn't work before, only some beginning part of data was inserted
Hello, <span>World</span>– onlyHello,here<p>first</p><p>second</p>– only<p>first</p>here
So I propose to insert all DOMNodes from the string coming to DomHelperTrait::replaceNodeContent().
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | interdiff.txt | 2.37 KB | slashrsm |
| #23 | 2602316_22.patch | 5.74 KB | slashrsm |
| #19 | 2602316-12.patch | 3.83 KB | wim leers |
Comments
Comment #2
andreymaximov commentedPatch
Related to https://github.com/drupal-media/embed/pull/13
Comment #3
andreymaximov commentedComment #4
wim leersFirst, let's show that this patch's new test coverage indeed fails without the other changes.
I didn't change anything, I only rerolled it.
Comment #8
wim leersThis is basically exactly the same problem as #2567561: Captioned elements and their children are removed when theme debugging on. We should use the same solution as Drupal core uses.
(The current code assumes only one DOM node will be present:
This is identical to
FilterCaption's buggy logic and what #2567561: Captioned elements and their children are removed when theme debugging on is fixing.Comment #9
wim leersA duplicate of this bug was reported against the Entity Embed module: #2541984: <drupal-entity>is not replaced when twig debugging is enabled. It's a duplicate, because Entity Embed uses Embed's
DomHelperTrait.Comment #10
wim leersThis is now blocking #2547085: Remove the <drupal-entity>/<div> placeholder instead of embedding the entity as a child, which is blocking #2628358: Disallow <div>, only allow <drupal-entity>, which again blocks its parent issue.
Hence, marking this critical, since it blocks so much.
Comment #11
wim leersThis is an unnecessary API change.
So, instead of changing an API, let's just use the same solution that will land in Drupal 8 core: the one at #2567561: Captioned elements and their children are removed when theme debugging on.
Tests still needed!
Comment #15
wim leersTransplanted the tests written by @AndreyMaximov: modified them so they don't expect that API change anymore. In fact, having done that, I'm 90% certain he introduced that API change to simplify testability.
Fortunately, once you start using a data provider, that's not really necessary anymore :)
Comment #19
wim leersOops. I unchecked the box for the non-FAIL patch. Hence it wasn't tested. Re-uploading that one.
Comment #20
wim leersThere we go. Green :)
Comment #21
dave reid@WimLeers Should setNodeContent() also be fixed in the same way?
Comment #22
dave reidD'oh, no of course setNodeContent() doesn't need the same fix.
Comment #23
slashrsm commentedsetNodeContent() apparently can handle string that consist of multiple nodes. Uploading updated test that proves that.
Comment #24
slashrsm commentedI will go ahead and fix this as there are patches that are waiting for this. Thanks!
Comment #33
dave reid