Skip to content

The library can crash if document.elementFromPoint returns null #179

@diesieben07

Description

@diesieben07

If document.ElementFromPoint returns null, then this if-statement is skipped and execution falls off the end of the function, without any return. This means the function returns undefined. Callers of this function only check for null, not undefined. Specifically this if-statement makes it so that in this case the controller assumes there is an element causing "Cannot read property X of undefined" errors further down the line.
The simplest fix is simply a return null; at the end of elementFromPoint.

I would suggest enabling TypeScript's strictNullChecks option, which can guard against problems like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions