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

Add component pre-init hook #191

Merged
merged 3 commits into from
Feb 14, 2024
Merged

Add component pre-init hook #191

merged 3 commits into from
Feb 14, 2024

Conversation

micaww
Copy link
Contributor

@micaww micaww commented Feb 13, 2024

Adds an event that's dispatched before first template call in Panel components.

@@ -470,6 +470,8 @@ class Component extends WebComponent {
}
}

this.dispatchEvent(new CustomEvent(`preComponentInitialized`, {detail: {el: this}, bubbles: true, composed: true}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need el: this? Surely you can get that from the event object already

Copy link
Contributor Author

@micaww micaww Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah actually, im not sure why but event.target doesn't always equal the dispatching component in the handler. sometimes it is different components altogether unless i pass it explicitly like this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still much cleaner than the prototype / prop overriding but still a goot solution

Copy link
Member

@tdumitrescu tdumitrescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway yeah, if it's taking you too long to debug why you're not finding events with the correct target, no need to block on it.

@micaww micaww merged commit 5915fa1 into master Feb 14, 2024
4 checks passed
@micaww micaww deleted the micah-preinitializehook branch February 14, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants