DOM binder fixes (#564)

* Fix incorrect updateValue function

* Add source
This commit is contained in:
toasted-nutbread 2020-05-29 19:44:53 -04:00 committed by GitHub
parent 9d40955fc8
commit 37f0396f1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -22,8 +22,9 @@
*/ */
class DOMSettingsBinder { class DOMSettingsBinder {
constructor({getOptionsContext, transforms=null}) { constructor({getOptionsContext, source=null, transforms=null}) {
this._getOptionsContext = getOptionsContext; this._getOptionsContext = getOptionsContext;
this._source = source;
this._defaultScope = 'profile'; this._defaultScope = 'profile';
this._dataBinder = new DOMDataBinder({ this._dataBinder = new DOMDataBinder({
selector: '[data-setting]', selector: '[data-setting]',
@ -97,7 +98,7 @@ class DOMSettingsBinder {
} }
settingsTargets.push(target); settingsTargets.push(target);
} }
return this._transformResults(await api.modifySettings(settingsTargets), targets); return this._transformResults(await api.modifySettings(settingsTargets, this._source), targets);
} }
_transform(value, transform, metadata, element) { _transform(value, transform, metadata, element) {

View File

@ -108,8 +108,8 @@ class DOMDataBinder {
if (addedNodes.length !== 0 || addedNodes.length !== 0) { if (addedNodes.length !== 0 || addedNodes.length !== 0) {
const observer = this._elementMap.get(target); const observer = this._elementMap.get(target);
if (typeof observer !== 'undefined') { if (typeof observer !== 'undefined' && observer.hasValue) {
observer.updateValue(); this._setElementValue(observer.element, observer.value);
} }
} }
} }