working with Components
See original GitHub issueHi, sorry for another question in short period of time,
but how can we implement the concept of components correctly with set-dom? what i mean is that let us take the below example
<div id="wrapper">
<h1>header</h1>
<component-parent>
<div>dynamic text</div>
<component-child-a></component-child-a>
<component-child-b></component-child-b>
</component-parent>
</div>
now if dynamic text change, it is no issue, but as you would expect the above component-child-a
and component-child-b
HTML is just placeholder, when we parse the tags above we replace them with dynamic component’s content ( same like react or any other framework), so let us say they will become as below
<div id="wrapper">
<h1>header</h1>
<component-parent>
<div>dynamic text</div>
<component-child-a>
<h1>component content after parsing</h1>
</component-child-a>
<component-child-b>
<component-child-c>component content after parsing</component-child-c>
</component-child-b>
</component-parent>
</div>
this problem now is that say we want to change <div>dynamic text</div>
on parent component to <div>new dynamic text</div>
if we diff again, component-child-a
and component-child-b
will loose their dynamic injected content. the same would happen if we click a button to inject component dynamically.
the point is that how to avoid that in your experience ?
should set-dom have some option to ignore diffing elements if they start with a tag name, attribute in ignore list somewhere, ? or set-dom already has solution for that ?
the other issue is that how to handle relationship between parent and child components from timing point of view, in simple words how do we guarantee if parent component had attached
hook, and there is some code to communicate with child component or vice versa, both of them are available?
i am talking the same as React components and child components and passing params to them.
thanks again in advanced 😃
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (5 by maintainers)
Since set-dom works with strings I just use functions that return strings as my components.
For example with as-html.
index.js
a.js
b.js
Does that make sense?
@DylanPiercey thank you very much man this is awesome!