Skip to content

Consider not sealing ValidityState #141

Description

We use this polyfill as part of our Jest-based component tests which render Lit components.

Some compontents extend ValidityState of the attached internals with custom properties. This may be debatable if good practice at all but it works in modern browsers without restrictions.

However, our Jest tests fail with this TypeError: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_define_property_object_not_extensible

TypeError: can't define property "x": "obj" is not extensible

The reason is because ValidityState gets sealed in its constructor: https://github.com/calebdwilliams/element-internals-polyfill/blob/main/src/ValidityState.ts#L18

Was there any reason to implement it this way? Could you consider not sealing the object to allow for extension?

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