From 03f8c92a36c98e2358dcc61c3dbaf83d60e9bbd7 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Tue, 18 Feb 2014 12:29:13 -0800 Subject: [PATCH] index: try/catch the Object.getOwnPropertyDescriptor() call On IE10 and probably others, this was a source of the `inspect()` call failing --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 373bd6d..7db64f9 100644 --- a/index.js +++ b/index.js @@ -311,8 +311,14 @@ function formatValue(ctx, value, recurseTimes) { function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { var name, str, desc; desc = { value: value[key] }; - if (Object.getOwnPropertyDescriptor) { - desc = Object.getOwnPropertyDescriptor(value, key) || desc; + try { + // ie10 › Object.getOwnPropertyDescriptor(window.location, 'hash') + // throws TypeError: Object doesn't support this action + if (Object.getOwnPropertyDescriptor) { + desc = Object.getOwnPropertyDescriptor(value, key) || desc; + } + } catch (e) { + // ignore } if (desc.get) { if (desc.set) {