Project

General

Profile

Actions

Bug #11180

closed

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

Added by Roel Standaert almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Roel Standaert
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 1 (0 open1 closed)

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

Actions
Actions #1

Updated by Roel Standaert almost 2 years ago

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

Updated by Roel Standaert almost 2 years ago

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

Updated by Roel Standaert almost 2 years ago

  • Assignee deleted (Korneel Dumon)
Actions #4

Updated by Marnik Roosen almost 2 years ago

  • Assignee set to Marnik Roosen
Actions #5

Updated by Roel Standaert almost 2 years ago

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

Updated by Roel Standaert almost 2 years ago

  • Status changed from Implemented @Emweb to Resolved
Actions #7

Updated by Roel Standaert almost 2 years ago

  • Assignee changed from Marnik Roosen to Roel Standaert
Actions #8

Updated by Roel Standaert almost 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF