Skip to content

Add compatibility with ShadowDOM/web components #171

@smiller-lintech

Description

@smiller-lintech

just-validate works great in standard web pages, but had problems when I went to use it in a Web Component. The component was written in LIT, but this is likely a more global issue.

To resolve the issues with web components, I downloaded the 4.3 .es.js module and added a setting "useShadowRoot", defaulted to false, and added an internal variable in the "initialize" method:

this.myDOMRoot = (this.globalConfig.useShadowRoot ? this.shadowRoot : document);

And replaced any "document.whatever" with "this.myDOMRoot.whatever" (about 5-10 instances). This change made everything work as expected in the web component. It would be nice to have this option or some other sort of document root option integrated into future releases.

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