Skip to content

Tag: web-component

Adding an event within a WebComponent

I want to create a Web Component. I use a ShadowDom and after generating a list I want to add a click Event to each element of the list. But I wonder how to access the list. Neither the document nor the template shows me the items after a querySelect. My question: How can I access the generated list within

Why I can not call method of WebComponent?

I wonder why I cannot call a method defined in web-component if I attached this component via .append instead of using tag name inside the template. Below I am providing few examples. One is not working(throwing an error). I wonder why this first example is throwing this error. Example 1 In this example, I am…

JavaScript: refer to anonymous class static variable

Following this google tutorial on web components, and I like the way the author uses an anonymous class in the customElements.define function call, as it avoids even more brackets when creating an immediately invoked function call. I am using a static class variable to store the template element, so it’…