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),
|
||||
\_)
|
||||
}) => 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 {
|
||||
field propValue: any = (node as any)[property];
|
||||
assert P.UIChangeableProperty(selector, property, propValue.value);
|
||||
const facet = Turn.activeFacet;
|
||||
const handlerClosure = (_e: Event) => facet.turn(() => {
|
||||
propValue.value = (node as any)[property];
|
||||
selectorMatch(document.body, selector).forEach(node => {
|
||||
field propValue: any = (node as any)[property];
|
||||
assert P.UIChangeableProperty(selector, property, propValue.value);
|
||||
const facet = Turn.activeFacet;
|
||||
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);
|
||||
on stop eventUpdater('change', handlerClosure, false)(node);
|
||||
stop on (needRescan.value) {
|
||||
needRescan.value = false;
|
||||
installOrReplaceHandlers();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
installOrReplaceHandlers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue