Skip to content
Snippets Groups Projects

Get and HTML DOMElement of the fragment and append it

1 unresolved thread

Closes #3412644

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
113 121 '#item' => NULL,
114 122 ];
123
115 124 $fragment_node = $dom->createDocumentFragment();
116 125 $html = Html::normalize($this->renderer->render($build));
117 $fragment_node->appendXML($html);
126 // Trim to ensure the first child is a DOMElement.
127 $html = trim($html);
128 // Build a new DOMDocument for the HTML.
129 $fragment_dom = Html::load($html);
130 // Get the body element of the new document.
131 $fragment_body = $fragment_dom->getElementsByTagName('body')->item(0);
132 // Import the new (header) node onto the original DOMDocument.
133 $fragment_import_node = $dom->importNode($fragment_body->firstChild, true);
134 $fragment_node->appendChild($fragment_import_node);
135
  • Liam Morland added 1 commit

    added 1 commit

    Compare with previous version

  • Eric Smith mentioned in merge request !12 (merged)

    mentioned in merge request !12 (merged)

  • Please register or sign in to reply
    Loading