Rescan when a fragment changes, to keep property monitor event handlers installed
This commit is contained in:
parent
419adba79b
commit
cc3fac620c
|
@ -423,18 +423,32 @@ function spawnUIChangeablePropertyFactory(ds: Ref) {
|
||||||
\Q.lit($property: string),
|
\Q.lit($property: string),
|
||||||
\_)
|
\_)
|
||||||
}) => spawn named ['UIChangeableProperty', selector, property] {
|
}) => spawn named ['UIChangeableProperty', selector, property] {
|
||||||
selectorMatch(document.body, selector).forEach(node => {
|
field needRescan: boolean = false;
|
||||||
|
|
||||||
|
on asserted P.UIFragmentVersion($_i, $_v) => needRescan.value = true;
|
||||||
|
// TODO: don't be so crude about this ^. On the one hand, this
|
||||||
|
// lets us ignore UIFragmentVersion records coming and going; on
|
||||||
|
// the other hand, we do potentially a lot of redundant work.
|
||||||
|
|
||||||
|
function installOrReplaceHandlers() {
|
||||||
react {
|
react {
|
||||||
field propValue: any = (node as any)[property];
|
selectorMatch(document.body, selector).forEach(node => {
|
||||||
assert P.UIChangeableProperty(selector, property, propValue.value);
|
field propValue: any = (node as any)[property];
|
||||||
const facet = Turn.activeFacet;
|
assert P.UIChangeableProperty(selector, property, propValue.value);
|
||||||
const handlerClosure = (_e: Event) => facet.turn(() => {
|
const facet = Turn.activeFacet;
|
||||||
propValue.value = (node as any)[property];
|
const handlerClosure = (_e: Event) => facet.turn(() => {
|
||||||
|
propValue.value = (node as any)[property];
|
||||||
|
});
|
||||||
|
eventUpdater('change', handlerClosure, true)(node);
|
||||||
|
on stop eventUpdater('change', handlerClosure, false)(node);
|
||||||
});
|
});
|
||||||
eventUpdater('change', handlerClosure, true)(node);
|
stop on (needRescan.value) {
|
||||||
on stop eventUpdater('change', handlerClosure, false)(node);
|
needRescan.value = false;
|
||||||
|
installOrReplaceHandlers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
installOrReplaceHandlers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue