Skip to content

Commit

Permalink
Fix invalid value check for entry-common.js
Browse files Browse the repository at this point in the history
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 #643

Differential Revision: D6413569

Pulled By: emilsjolander

fbshipit-source-id: a42a66710a3ca578b5c25ecef8722f9c3f082b73
  • Loading branch information
larsonjj authored and facebook-github-bot committed Nov 27, 2017
1 parent c7f7ba2 commit e566fcc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions javascript/sources/entry-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e566fcc

Please sign in to comment.