Fix infinite event listener ping-pong destroying settings page #1308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Regression introduced in #1270 (ecd9ffc).
The newly introduced
'element'
type for dom data binder to update things which are not any type of input (checkboxes, text inputs, etc) can cause an infinite loop when updating the value.There is a potential ping-pong between https://github.com/themoeway/yomitan/blob/ecd9ffc3d1965c4835686b814cbae8309ad0f398/ext/js/dom/dom-data-binder.js#L149-L168 and https://github.com/themoeway/yomitan/blob/ecd9ffc3d1965c4835686b814cbae8309ad0f398/ext/js/dom/dom-data-binder.js#L211-L216
When the value is updated by one of them, the other triggers, updating it again, triggering the other, and so on. This can occur any time the dictionary aliases in the settings page are updated, including when it is initially loaded.
I've added a guard against
'element'
being updated by_onObserverChildrenUpdated
. The'element'
type can be expected to have special handling in all cases and should not need to use this.I've also reverted the styling change that was applied to
_onObserverChildrenUpdated
in the dictionary aliases pr to make callingthis._setElementValue(element, observer.value);
appear as a more explicit action instead of a default action.Tested on Firefox and Chromium.