Project

General

Profile

Bug #11180

Regression in Wt 4.9.0: widget set mode fails with classList is undefined error

Added by Roel Standaert about 1 month ago. Updated 11 days ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
12/23/2022
Due date:
% Done:

100%

Estimated time:

Description

Using the widget set example I'm now greeted with:

Wt internal error; code: undefined, description: p.childNodes[i].classList is undefined

Or:

Wt internal error; code: undefined, description: Cannot read properties of undefined (reading 'contains')

This is due to the removal of jQuery. insertAt in Wt.js used to contain:

var i, j, il;
for (i = 0, j = 0, il = p.childNodes.length; i < il; ++i) {
  if ($(p.childNodes[i]).hasClass("wt-reparented"))
    continue;
  // ...
}

This was changed to:

for (let i = 0, j = 0, il = p.childNodes.length; i < il; ++i) {
  if (p.childNodes[i].classList.contains("wt-reparented")) {
    continue;
  }
  // ...
}

However, childNodes iterates over all nodes, not just Elements, so if e.g. a text node is encountered it has no classList member.

A simple fix could be to change the code to:

for (let i = 0, j = 0, il = p.childNodes.length; i < il; ++i) {
  if (p.childNodes[i].classList?.contains("wt-reparented")) {
    continue;
  }
  // ...
}

I'm not sure if it should maybe only iterate over Elements, though...


Related issues

Has duplicate Bug #11232: Crash when using WidgetSetClosed01/08/2023

Actions
#1

Updated by Roel Standaert 23 days ago

  • Status changed from InProgress to Review
  • Assignee changed from Roel Standaert to Korneel Dumon
#2

Updated by Roel Standaert 23 days ago

  • Has duplicate Bug #11232: Crash when using WidgetSet added
#3

Updated by Roel Standaert 18 days ago

  • Assignee deleted (Korneel Dumon)
#4

Updated by Marnik Roosen 18 days ago

  • Assignee set to Marnik Roosen
#5

Updated by Roel Standaert 16 days ago

  • Status changed from Review to Implemented @Emweb
  • % Done changed from 0 to 100
#6

Updated by Roel Standaert 16 days ago

  • Status changed from Implemented @Emweb to Resolved
#7

Updated by Roel Standaert 16 days ago

  • Assignee changed from Marnik Roosen to Roel Standaert
#8

Updated by Roel Standaert 11 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF