ken107 / databind-js

A powerful and flexible MVC data binding library
MIT License
16 stars 5 forks source link

Issue with delayed-loaded view on a repeater #2

Open ken107 opened 3 years ago

ken107 commented 3 years ago

<div bind-repeater-if="#item ? 1 : 0" bind-view="Item">

If the view is ready at the time of binding, then no problem. However if it is not ready, we automatically create a boolean repeater in-place to represent its delayed loading state. This results in coincident repeaters.

We currently cannot handle coincident repeaters. Each repeater needs an anchor against which to attach the spawned elements. The second repeater wrongly uses the first repeater's ephemeral container as anchor.

ken107 commented 3 years ago

We want to allow dynamic view loading, this means readiness of a view at the time of binding is unpredictable. If bind-repeater and bind-view are allowed on the same element, coincident-repeater errors will happen unpredictably. Thus, we must either disallow bind-repeater and bind-view on the same element, or make coincident repeaters work.

Coincident repeaters, i.e. two or more bind-repeater directives on the same element, generally do not make sense. The repeaters should instead be nested, like TDs inside TRs, for proper multidimensional structuring. The solution thus could simply be to convert coincident repeaters to nested repeaters automatically.