Closed Prinzhorn closed 6 years ago
This goes even further. The LayoutDependencyType needs to be updated when an element leaves or enters the DOM. Maybe we just update EVERYTHING when an element disconnects or connects? Or is that overkill? Maybe it only affects the layout behavior anyway. Or maybe not. There might be behaviors (e.g. signal) that search for events using a selector. It needs to be updated as well.
What we basically need to do is to call _updateProperty
for dependencies
with the same rawValue (e.g. inherit
). This will get the correct elements from the DOM and the guide-layout will automatically do its thing due to layout:update event.
Now the thing is that this should be a general purpose solution. Right now we have layoutdependency
and template
that depend on the DOM. There will be at least a third one cssselector
. These should all be updated when a new element (MeisterComponent) connects or disconnects from the DOM. This is not related to the layout behavior at all, it's just the first place that we ran into it.
Now we're talking: if you create a new disconnected element-meister the behaviors will crash, since they expect the element to be connected. Luckily, there is a isConnected
property and we can postpone behavior scheduling.
Currently we detach every single behavior when an element is disconnected. However, the dependency check uses el.parentNode. We should have a special mode for detaching/cleaning up everything. This is different from regular batch detaching.