Warning: DOMNode::appendChild(): Document Fragment is empty

Created on 23 February 2022, over 2 years ago
Updated 24 November 2023, 7 months ago

Problem/Motivation

I don't want to show the "Back to top" button/link. I've found only one legal way: remove all HTML code from the toc-back-to-top.html.twig. After that I get next warning in logs:

Message	Warning: DOMNode::appendChild(): Document Fragment is empty in Drupal\toc_api\TocBuilder->renderContent() (line 87 of /var/www/drupal/web/modules/contrib/toc_api/src/TocBuilder.php)

Steps to reproduce

  • install the module + toc_filter, configure it (token in my case is used)
  • delete all HTML code in toc-back-to-top.html.twig
  • flush cache, open a page with content
  • check logs

Proposed resolution

  • provide an option to hide the "Back to top" button
  • as a hotfix: add a condition to check if a Document Fragment is not empty before appending to a DOM

Remaining tasks

Develop a patch.

User interface changes

tbd

API changes

tbd

Data model changes

tbd

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡ͺGeorgia Chalk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024