I have build my web component DataUint
and assigned it a tag <data-uint>
like this:
class DataUint extends HTMLElement
{
...
set value(x) { ... }
...
}
customElements.define("data-uint", DataUint);
When creating and accessing a component like this:
x = document.createElement('data-uint');
x.value = 10;
the call to value
indeed calls the setter method and performs its function.
However when I built-in my component in the html code:
<body>
<data-uint id='num'></data-uint>
</body>
and trying to access/use it like this:
x = body.children[0];
x.value = 10;
the call to value
sets a new property to Element that is referenced by x, but never calls the setter method of the web component.
The x
however refers to the correct element on the page (my component) which I verified by calling other standard Element methods. It looks like this access method is returning a generic Element
ignoring specializations.
Question:
I guess I am missing some basic concept here. How do I access html-defined component from JavaScript in a way that will allow me to use its member functions?