From e566fcca08c86b5614a6d164c6da0aa537a34d33 Mon Sep 17 00:00:00 2001 From: Jake Larson Date: Mon, 27 Nov 2017 05:08:54 -0800 Subject: [PATCH] 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 --- javascript/sources/entry-common.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javascript/sources/entry-common.js b/javascript/sources/entry-common.js index 09f50346..b67b3292 100644 --- a/javascript/sources/entry-common.js +++ b/javascript/sources/entry-common.js @@ -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);