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

(Feature Request) Make autoInit return the initialized components #1329

Closed
blikblum opened this issue Sep 19, 2017 · 2 comments
Closed

(Feature Request) Make autoInit return the initialized components #1329

blikblum opened this issue Sep 19, 2017 · 2 comments

Comments

@blikblum
Copy link
Contributor

Feature Request

Return the components initialized by a call to autoInit

Motivation

Currently, when integrating mdc with a framework or with custom elements is necessary to individually create the components, store its references and destroy when appropriate. With autoInit is possible to accomplish the first step with one call (create the components) but will not provide the means to destroy the component instances

Use case

By autoInit returning the initialized components we could write components like the below which will initialize (and) finalize all mdc components with auto-init attribute


class MDAutoComponent extends HTMLElement {
  connectedCallback() {
    this.mdcComponents = mdc.autoInit(this)
  }
  disconnectedCallback() {
    this.mdcComponents.forEach((comp) => comp.destroy())
  }
}
@amsheehan
Copy link
Contributor

Seems reasonable. Is this something you would like to change and make a pull request for?

@blikblum
Copy link
Contributor Author

Is this something you would like to change and make a pull request for?

Done

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

2 participants