LivelyKernel / lively4-core

A Self-supporting, Web-based Development Environment
https://lively-kernel.org/lively4/lively4-core/start.html
MIT License
73 stars 25 forks source link

Webcomponents do not update when internal components change #101

Open onsetsu opened 7 years ago

onsetsu commented 7 years ago

Lets say I have a WebComponent lively-tool that uses another Webcomponent lively-list internally in its shadow root.

Now when I change lively-list.js, neighter the internal lively-list nor the lively-tool updates.

Can we check shadow roots too?

JensLincke commented 7 years ago

The code that is responsible for this is in src/client/lively.js

static async updateTemplate(html) {
    var tagName = await components.reloadComponent(html);
    if (!tagName) return;

    _.each($(tagName), function(oldInstance) {
      if (oldInstance.__ingoreUpdates) return;
   ...

So what should happen when we change lively-list? a) the instance is locally migrated inside the shadow-root, similar to "global" instances. b) migrated the topmost element

(a) should be faster, but we break all the references the parent component might have in its objects (we could deal with that) and its closures (we cannot deal with this at the moment). We are missing a smalltalk like become to make this work. Maybe we can develop (a1) where we can reuse the existing instance and change all properties and state... etc... like keeping a hull or using proxies in the first place or similar strategies.

The approach of replacing and migrating instances at the moment is more like reloading the whole page.

JensLincke commented 4 years ago

we could generalize our identity preserving object migration through replacing shadow content and merging only new content as needed.