Re: [WICG/webcomponents] HTML Modules: JavaScript Scoping of ShadowDom Children (Issue #959)

@clshortfuse The only problem with this is that it still scopes the event to the element/node, and not the class itself. At that point, any reference to `this` inside `handleClick` (like `this.showLoadingSpinner()` as an example) would fail because the `<button>` element does not an element `this.showLoadingSpinner()`.

------------------------------

I also wanted to address one point that someone else brought up in a different conversation. The concern was that you would lose access to the `<button>` element via `this`. But given the fact that you have access to `event.target`, this won't be a problem.

The general problem right now is that there is no intuitive way to reference the class associated with the custom element inside the DOM of the custom element. The class can reference the DOM, but the DOM cannot reference the class instance. This makes libraries like React, Vue.js, and others far more attractive to developers, which becomes problematic when trying to make the argument for leveraging agnostic web components.

In my personal opinion, for whatever its worth, this is probably one of the single biggest pieces that could be introduced to the web component standards to bolster the adoption of pure web components: Intuitive access to the class instance via `this` from within the DOM.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/959#issuecomment-1367006908
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/959/1367006908@github.com>

Received on Thursday, 29 December 2022 01:02:18 UTC