Skip to content

[ui5-table]: TypeError: Cannot use 'in' operator to search for 'isTable' in null when table rows are destroyed while pending re-render #13701

@AnastasiyaVavilava

Description

@AnastasiyaVavilava

Bug Description

When ui5-table-row elements are removed from the DOM (e.g. because a parent framework re-renders the list with new data), a pending onBeforeRendering call fires on the detached row. At that point this.parentElement is null. The _table getter passes this null to isInstanceOfTable(), which calls createInstanceChecker, which does "isTable" in null — causing an uncaught TypeError.

Root cause

In TableRowBase.js:

get _table() {
    const element = this.parentElement; // can be null after detach
    return isInstanceOfTable(element) ? element : undefined;
}

In @ui5/webcomponents-base/dist/util/createInstanceChecker.js:

function createChecker(prop) {
    return (object) => {
        return object !== undefined && prop in object && object[prop] === true;
        //     ^^^^^^^^^^^^^^^^^^^ null is not guarded — "prop in null" throws
    };
}

The in operator throws TypeError if the right-hand operand is null. Only undefined is guarded.

Proposed fix

In createInstanceChecker.js (both dist/util/ and dist/prod/util/):

return object !== undefined && object !== null && prop in object && object[prop] === true;
Or alternatively guard in TableRowBase._table:

get _table() {
    const element = this.parentElement;
    return element && isInstanceOfTable(element) ? element : undefined;
}

Workaround

Patch node_modules/@ui5/webcomponents-base/dist/util/createInstanceChecker.js with patch-package.

Affected Component

ui5-table-row, ui5-table-header-row

Expected Behaviour

No response

Isolated Example

No response

Steps to Reproduce

  1. Use ui5-table with Angular (or any framework that re-renders the row list reactively)
  2. Render a table with rows
  3. Trigger a data reload that replaces all rows (e.e. search/filter reset)
  4. The framework destroys the old ui5-table-row elements while UI5's render queue still has a pending onBeforeRendering for them
  5. TypeError: Cannot use 'in' operator to search for 'isTable' in null is thrown

Log Output, Stack Trace or Screenshots

No response

Priority

High

UI5 Web Components Version

2.23.1

Browser

Chrome

Operating System

No response

Additional Context

No response

Organization

No response

Declaration

  • I’m not disclosing any internal or sensitive information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions