Fallback to legacy set/get in old versions of FF #6930
Merged
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.
#5746 introduced some issues with older (<22) versions of Firefox that prevent inputs from being properly updated, and fails to fire
componentDidMount
and any ref callbacks.In these old versions of Firefox, accessing the property descriptor of a prototype calculated the value, which caused it to throw exceptions in certain cases related to the DOM (see: https://bugzilla.mozilla.org/show_bug.cgi?id=520882). In this specific case, fetching the
value
of aninput
ortextarea
would fail withNS_ERROR_XPC_BAD_OP_ON_WN_PROTO
, which cascaded upwards, eventually getting caught by the transaction queue. This would prevent any other enqueued actions, such as runningcomponentDidMount
or establishing refs.This fix uses Firefox's deprecated
__lookupSetter__
and__lookupGetter__
methods as a fallback, which are supported in all versions where thegetOwnPropertyDescriptor
will fail. It has been spot tested on Firefox 4, 17, 21, and 46: all managed to run all lifecycle hooks and establish refs, and were able to set and update thevalue
of inputs.One remaining question is what to do when the catch block is reached and the lookup methods don't exist. In this case, descriptor will be undefined and will break below. This actually seems like reasonable behavior to me, because if we get that far we're in a bizarre, unsupported browser environment, and nothing should work.