From 17d2eb7153c2554e414e5353a8b3c87427a27109 Mon Sep 17 00:00:00 2001 From: jods Date: Fri, 31 Mar 2017 07:34:02 +0200 Subject: [PATCH] fix(pal-browser): regression in Function.name polyfill on iOS (#20) --- src/function-name.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/function-name.js b/src/function-name.js index 1252362..26676c6 100644 --- a/src/function-name.js +++ b/src/function-name.js @@ -2,7 +2,9 @@ if (typeof FEATURE_NO_IE === 'undefined') { // Fix Function#name on browsers that do not support it (IE): function test() {} - if (!test.name) { + // Fix: don't shorten to `!test.name` as minifiers may remove the `test` function name, + // which results in `test.name === ''`, which is falsy. + if (test.name === undefined) { Object.defineProperty(Function.prototype, 'name', { get: function() { let name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1];