Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create tests in all components to catch Error being thrown into the DOM when trying to create components via JavaScript #533

Open
Patrick-Daly-AA opened this issue Mar 28, 2024 Discussed in #529 · 0 comments

Comments

@Patrick-Daly-AA
Copy link
Contributor

Will need to follow work from #532

The goal is to create a test to handle this error case, and add it to every component and the generator.

Discussed in https://github.com/orgs/AlaskaAirlines/discussions/529

Originally posted by jordanjones243 March 21, 2024
An issue was brought to my attention recently with creating an instance of auro-popover through JavaScript that likely can come up in other components:

Basically, in most of our components, we have attributes that are applied to our custom elements. These attributes are usually initialized inside of our constructor and some are reflected onto the element in the DOM. Where the issue arises is when we try to create a component using the DOM (via JavaScript). An error is thrown because the DOM is complaining that it cannot create an element that already has attributes applied to it. In this case, we had our auro-popover component being created with an id attribute already being assigned a value in the constructor.

What we need to do is go through all of our components and move all of our attributes that are being reflected onto the components from being initialized in the constructor to the connectedCallback() function, which runs once an element is attached to the DOM.

This simple change from auro-popover can be used as a guide to make the change in any other component that can run into this issue:

@Patrick-Daly-AA Patrick-Daly-AA added wc-generator Type: Refactoring A code change that neither fixes a bug nor adds a feature Type: test labels Mar 28, 2024
@Patrick-Daly-AA Patrick-Daly-AA removed their assignment Mar 28, 2024
@jason-capsule42 jason-capsule42 removed the Type: Refactoring A code change that neither fixes a bug nor adds a feature label Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants