Skip to content

Guard 'content' against null in LoginLayout.onAttach #29

@coderabbitai

Description

@coderabbitai

Summary

In LoginLayout.onAttach, the content field is dereferenced at multiple points (appending to the element, setting the slot attribute, and executing JS) without a null check. If the layout attaches before routed content is available, this could throw a NullPointerException and potentially leave the overlay in a partially modified state.

Suggested fix

Add an early-return guard before the form replacement logic:

@Override
protected void onAttach(AttachEvent attachEvent) {
    super.onAttach(attachEvent);
    setOpened(true);
    if (content == null) {
        return;
    }
    // ... rest of the method
}

Context

This issue was identified during code review of PR #28 (comment: #28 (comment)). The concern originates from the original implementation and was not introduced by PR #28.

Reported by: @paodb

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Inbox (needs triage)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions