UIChangeableProperty

This commit is contained in:
Tony Garnock-Jones 2018-11-19 22:21:36 +00:00
parent 1c317f5134
commit 16719e1d07
2 changed files with 22 additions and 0 deletions

View File

@ -366,6 +366,23 @@ function splitClassValue(v) {
///////////////////////////////////////////////////////////////////////////
spawn named 'UIChangeablePropertyFactory' {
during Observe(P.UIChangeableProperty($selector, $property, _))
spawn named ['UIChangeableProperty', selector, property] {
on start selectorMatch(document, selector).forEach((node) => {
react {
field this.value = node[property];
assert P.UIChangeableProperty(selector, property, this.value);
const handlerClosure = Dataspace.wrapExternal((e) => { this.value = node[property]; });
on start eventUpdater('change', handlerClosure, true)(node);
on stop eventUpdater('change', handlerClosure, false)(node);
}
});
}
}
///////////////////////////////////////////////////////////////////////////
function escapeDataAttributeName(s) {
// Per https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset,
// the rules seem to be:

View File

@ -63,6 +63,11 @@ module.exports.UIAttribute = UIAttribute;
assertion type UIProperty(selector, property, value);
module.exports.UIProperty = UIProperty;
// Assertion. For clients to monitor the values of properties that,
// when changed, emit 'change' events.
assertion type UIChangeableProperty(selector, property, value);
module.exports.UIChangeableProperty = UIChangeableProperty;
// Messages.
// NOTE: These do not treat "class" specially!
message type SetAttribute(selector, attribute, value);