Fix invalid value check for entry-common.js

Summary:
`!Object.prototype.hasOwnProperty.call(methods, unit))` doesn't correctly return `true` when an unsupported value is passed into `setMaxWidth` within an Automator (macOS) javascript/cocoascript environment.

This PR fixes the issue and also adds the `value` information to the returned error to help with debugging
Closes https://github.com/facebook/yoga/pull/643

Differential Revision: D6413569

Pulled By: emilsjolander

fbshipit-source-id: a42a66710a3ca578b5c25ecef8722f9c3f082b73
This commit is contained in:
Jake Larson
2017-11-27 05:08:54 -08:00
committed by Facebook Github Bot
parent c7f7ba250c
commit e566fcca08

View File

@@ -156,8 +156,8 @@ module.exports = function (bind, lib) {
}
if (!Object.prototype.hasOwnProperty.call(methods, unit))
throw new Error(`Failed to execute "${fnName}": Unsupported unit.`);
if (!methods[unit])
throw new Error(`Failed to execute "${fnName}": Unsupported unit '${value}'`);
if (asNumber !== undefined) {
return methods[unit].call(this, ... args, asNumber);