Suppose you have a custom component container. This component will look at any html elements inside it and make desicions based on custom html attributes of those elements. For example, suppose there is a proportion attribute that could be used as follows:
<x-container>
<div proportion="0.2">
...
</div>
<div proportion="0.5">
...
</div>
<div proportion="0.3">
...
</div>
</x-container>
Forgetting dart for a second is this a reasonable thing to do with html attributes or is it an abuse? (Note: I am learning Dart and Web UI as my first attempt at web development - so this may be a bad idea).
If it is reasonable, I would like to nest containers:
<x-container>
<x-container proportion="0.3">
...
</x-container>
<x-container proportion="0.3">
...
</x-container>
<div proportion="0.4">
...
</div>
<x-container>
In general Container components themselves do not have or need proportion member variables, only their contained html elements may have proportion html attributes. But since a container can be a contained element I want it to be able to have such an html attribute. How can I set an html attribute in the instantiation of a component without it trying to call a dart method ("proportion=") on a member variable that does not and should not exist?
From the answer for How to pass a constant or literal data via an attribute while instantiating dart web component? it looks like the suggestion is attribute=value, but this attempts to set a member variable, which will not exist.