Closed eugeneware closed 7 years ago
nanocomponent v3.0.0
is out - don't think this issue is relevant anymore. Also released https://github.com/yoshuawuyts/microcomponent for a more high level take on the API of nanocomponent
@eugeneware thanks heaps for reporting though! :grin: - a refactor was due to solve issues like the one you were running into
Cool. Will check them out!
The use of a
placeholder
because it usesnanomorph
under the hood, means that the element that gets passed to the first argument fonupdate
is actually NOT the one that gets inserted into the document and returned by the first render. Thus, any attempt to modify that element has no impact on the actual DOM element.The root cause is that due to using
polite-element
the actual element that gets inserted is the placeholder element. Then the rendered element is used to diff and update the placeholder element. Thus theplaceholder
DOM element is the one that needs to be returned and provided to theonupdate
element and any other place that the element is passed in.Work around: Cache the element that gets passed into
onload
(this seems to be the right one) and use this inonupdate
, or don't use aplaceholder
element.Here's a test case that shows the behaviour.