Skip to content

Fallback to legacy set/get in old versions of FF #6930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/renderers/dom/client/inputValueTracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,28 @@ var inputValueTracking = {

var node = ReactDOMComponentTree.getNodeFromInstance(inst);
var valueField = isCheckable(node) ? 'checked' : 'value';
var descriptor = Object.getOwnPropertyDescriptor(
node.constructor.prototype,
valueField
);
var descriptor;
try {
// Accessing quick-stubbed properties of prototypes in older versions of
// Firefox will throw a NS_ERROR_XPC_BAD_OP_ON_WN_PROTO exception
descriptor = Object.getOwnPropertyDescriptor(
node.constructor.prototype,
valueField
);
} catch (e) {
var proto = node.constructor.prototype;
// Attempt to fall back to Firefox's deprecated setters / getters
if (
typeof proto.__lookupSetter__ === 'function' &&
typeof proto.__lookupGetter__ === 'function'
) {
descriptor = {
enumerable: true,
get: proto.__lookupGetter__(valueField),
set: proto.__lookupSetter__(valueField),
};
}
}

var currentValue = '' + node[valueField];

Expand Down