JS error related to Drupal.behaviors

Created on 13 May 2025, 2 days ago
Updated 14 May 2025, 1 day ago

Problem/Motivation

The function defined in the Drupal behavior attach property (js/views_timelinejs.js) is executed more than once when the page containing the timeline is viewed as logged in administrator/editor (i.e., with the admin toolbar). This results in a console error:

DOMMixins.js:35 Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
    at Rt.removeFrom (DOMMixins.js:35:19)
    at Xe._initLayout (Timeline.js:403:22)
    at Xe._onDataLoaded (Timeline.js:382:14)

as the 'removeChild' function is executed outside of the document context. Not sure, if only my environment is affected. The functionality of the timeline is not affected though, so the proposed fix below might be merely cosmetic.

Steps to reproduce

  • Drupal core 10.4.6
  • drupal/views_timelinejs 4.1.1
  • Timeline.js 3.8.18, locally served
  • Timeline view has been set up as a page

Proposed resolution

Wrapping the content of the attach function (js/views_timelinejs.js) with

if (context === document) {
	for (const key in settings.TimelineJS) {
	...
	}
}

seems to fix the JS error.

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇨🇦Canada dgloor

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.71.5 2024