Skip to content

[labs/virtualizer] Error when immediately re-rendering (before async connect code runs) #3481

@jpzwarte

Description

@jpzwarte

Which package(s) are affected?

Virtualizer (@lit-labs/virtualizer)

Description

When using the latest 0.0.0-masonry-preview-20221107225026 preview, the virtualizer throws an error on initial render. It still seems to work after that.

The error:

Virtualizer.js:168 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'detach')
    at Virtualizer.disconnected (Virtualizer.js:168:1)
    at VirtualizeDirective._makeVirtualizer (virtualize.js:74:1)
    at VirtualizeDirective._updateVirtualizerConfig (virtualize.js:59:1)
    at VirtualizeDirective.update (virtualize.js:48:1)
    at VirtualizeDirective._$resolve (directive.ts:134:1)
    at resolveDirective (lit-html.ts:1075:1)
    at ChildPart._$setValue (lit-html.ts:1353:1)
    at TemplateInstance._update (lit-html.ts:1181:1)
    at ChildPart._commitTemplateResult (lit-html.ts:1525:1)
    at ChildPart._$setValue (lit-html.ts:1375:1)

This is with the following markup:

        <tbody @visibilityChanged=${this.#onVisibilityChanged}>
          ${virtualize({ items: this.items, renderItem: item => this.renderItem(item) })}
        </tbody>

This does not throw any error with 0.7.2

Reproduction

Workaround

Is this a regression?

Yes. This used to work, but now it doesn't.

Affected versions

Failing in 0.0.0-masonry-preview-20221107225026, used to work in 0.7.2

Browser/OS/Node environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions