I have included a third party custom tag, and loading one external js file, the js file is appending few more elements to it. I tried to bind a click event for the element. But not working.
<!-- 3rd party custom element -->
<pin-location></pin-location>
After loading external js file, 3rd party plugin js file is appending few more elements like below
<each-pin><p>Pin1</p></each-pin>
<each-pin><p>Pin2</p></each-pin>
when i click on the paragraph i want send some analytics without removing existing event handlers from the paragraph.
I have tried below
customElements.get('pin-location', class extends HTMLElement {
connectedCallback() {
alert("hi");
this.attachShadow({mode: 'open'});
this.shadowRoot.firstElementChild.onclick = e => alert("Inner target: " + e.target.tagName);
}
});