From 0672e1af2a9fcc787e7c23b96dea60d290df5548 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 12 Oct 2023 12:14:13 -0700 Subject: [PATCH] [Fix] IE 8 has a broken `Object.defineProperty` --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index 10ee2ff..9534065 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,14 @@ var hasPropertyDescriptors = require('has-property-descriptors')(); var GetIntrinsic = require('get-intrinsic'); var $defineProperty = hasPropertyDescriptors && GetIntrinsic('%Object.defineProperty%', true); +if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + } catch (e) { + // IE 8 has a broken defineProperty + $defineProperty = false; + } +} var $SyntaxError = GetIntrinsic('%SyntaxError%'); var $TypeError = GetIntrinsic('%TypeError%');