| Index: sky/framework/sky-element/sky-element.sky
|
| diff --git a/sky/framework/sky-element/sky-element.sky b/sky/framework/sky-element/sky-element.sky
|
| index a76874a5f1215af1bbefca5594b9edc2b2c1c2e8..7b7933ab35709505eee6b2118c3228a6a28ed7ea 100644
|
| --- a/sky/framework/sky-element/sky-element.sky
|
| +++ b/sky/framework/sky-element/sky-element.sky
|
| @@ -160,6 +160,8 @@ class SkyElement extends HTMLElement {
|
|
|
| createdCallback() {
|
| this.isAttached = false;
|
| + this.propertyBindings = null;
|
| + this.dirtyPropertyBindings = null;
|
| this.created();
|
|
|
| Object.preventExtensions(this);
|
| @@ -208,6 +210,8 @@ class SkyElement extends HTMLElement {
|
| }
|
|
|
| notifyPropertyChanged(name, oldValue, newValue) {
|
| + if (oldValue == newValue)
|
| + return;
|
| var notifier = Object.getNotifier(this);
|
| notifier.notify({
|
| type: 'update',
|
| @@ -217,6 +221,38 @@ class SkyElement extends HTMLElement {
|
| var handler = this[name + 'Changed'];
|
| if (typeof handler == 'function')
|
| handler.call(this, oldValue, newValue);
|
| + this.schedulePropertyBindingUpdate(name);
|
| + }
|
| +
|
| + addPropertyBinding(name, binding) {
|
| + if (!this.propertyBindings)
|
| + this.propertyBindings = new Map();
|
| + this.propertyBindings.set(name, binding);
|
| + }
|
| +
|
| + getPropertyBinding(name) {
|
| + if (!this.propertyBindings)
|
| + return null;
|
| + return this.propertyBindings.get(name);
|
| + }
|
| +
|
| + schedulePropertyBindingUpdate(name) {
|
| + if (!this.dirtyPropertyBindings) {
|
| + this.dirtyPropertyBindings = new Set();
|
| + Promise.resolve().then(this.updatePropertyBindings.bind(this));
|
| + }
|
| + this.dirtyPropertyBindings.add(name);
|
| + }
|
| +
|
| + updatePropertyBindings() {
|
| + for (var name of this.dirtyPropertyBindings) {
|
| + var binding = this.getPropertyBinding(name);
|
| + if (binding) {
|
| + binding.setValue(this[name]);
|
| + binding.discardChanges();
|
| + }
|
| + }
|
| + this.dirtyPropertyBindings = null;
|
| }
|
| };
|
|
|
|
|