Fix stale locale binding surviving reassignment to a literal/different value - #703
Open
Gulvan0 wants to merge 1 commit into
Open
Fix stale locale binding surviving reassignment to a literal/different value#703Gulvan0 wants to merge 1 commit into
Gulvan0 wants to merge 1 commit into
Conversation
…t value
A component property once bound to a {{key}} locale binding kept reverting to
that key's value on later locale changes even after being reassigned to a
literal (or a different key), since the generated isString setter only ever
registered a binding, never unregistered one for a plain-value reassignment.
Add LocaleManager.unregisterProperty(component, prop) for clearing a single
property's binding (unlike the existing all-or-nothing unregisterComponent),
and call it from the generated setter whenever the new value isn't itself a
binding. Guard it with a new isRefreshing flag set around refreshFor's own
Reflect.setProperty calls, since those re-invoke the same setter with an
already-resolved (non-{{}}) value - without the guard a freshly registered
binding would immediately unregister itself the first time it was applied.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Demo: http://haxeui.org/builder/?a0a12ea2
Press "Set fixed", then press "Change locale"
A component property once bound to a {{key}} locale binding kept reverting to that key's value on later locale changes even after being reassigned to a literal (or a different key), since the generated isString setter only ever registered a binding, never unregistered one for a plain-value reassignment.
Add LocaleManager.unregisterProperty(component, prop) for clearing a single property's binding (unlike the existing all-or-nothing unregisterComponent), and call it from the generated setter whenever the new value isn't itself a binding. Guard it with a new isRefreshing flag set around refreshFor's own Reflect.setProperty calls, since those re-invoke the same setter with an already-resolved (non-{{}}) value - without the guard a freshly registered binding would immediately unregister itself the first time it was applied.