From 3f26323fe4205d3737670f86967308fbc2dfceac Mon Sep 17 00:00:00 2001 From: Daniel Ciao Date: Tue, 11 Jul 2017 14:17:20 -0700 Subject: [PATCH 1/5] Fix accessing attributes that don't inherit Object --- debug/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debug/index.js b/debug/index.js index 4bb2e7ee78..8c32cc334d 100644 --- a/debug/index.js +++ b/debug/index.js @@ -70,7 +70,7 @@ if (process.env.NODE_ENV === 'development') { if (attributes) { props = Object.keys(attributes).map(attr => { - return `${attr}=${JSON.stringify(attributes[attr] + '')}`; + return `${attr}=${JSON.stringify(Object.prototype.toString.call(attributes[attr]))}`; }); } @@ -82,4 +82,4 @@ if (process.env.NODE_ENV === 'development') { }; require('preact/devtools'); -} \ No newline at end of file +} From 857e957ab0cbb28d9b176a2be6ea22ba6cb96207 Mon Sep 17 00:00:00 2001 From: Daniel Ciao Date: Tue, 11 Jul 2017 14:52:28 -0700 Subject: [PATCH 2/5] Use object's toString if it exists --- debug/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/debug/index.js b/debug/index.js index 8c32cc334d..1cdfeda310 100644 --- a/debug/index.js +++ b/debug/index.js @@ -70,7 +70,17 @@ if (process.env.NODE_ENV === 'development') { if (attributes) { props = Object.keys(attributes).map(attr => { - return `${attr}=${JSON.stringify(Object.prototype.toString.call(attributes[attr]))}`; + const attrValue = attributes[attr]; + let attrValueString; + + // If it is an object but doesn't have toString(), use Object.toString + if (Object(attrValue) === attrValue && !attrValue.toString) { + attrValueString = Object.prototype.toString.call(attrValue) + } else { + attrValueString = attrValue + ''; + } + + return `${attr}=${JSON.stringify(attrValueString)}`; }); } From f11713205108feef218149f9bad3bedbfd1c771d Mon Sep 17 00:00:00 2001 From: Daniel Ciao Date: Tue, 11 Jul 2017 14:54:12 -0700 Subject: [PATCH 3/5] Fix spacing --- debug/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/debug/index.js b/debug/index.js index 1cdfeda310..0a374144e2 100644 --- a/debug/index.js +++ b/debug/index.js @@ -70,17 +70,17 @@ if (process.env.NODE_ENV === 'development') { if (attributes) { props = Object.keys(attributes).map(attr => { - const attrValue = attributes[attr]; - let attrValueString; - - // If it is an object but doesn't have toString(), use Object.toString - if (Object(attrValue) === attrValue && !attrValue.toString) { - attrValueString = Object.prototype.toString.call(attrValue) - } else { - attrValueString = attrValue + ''; - } - - return `${attr}=${JSON.stringify(attrValueString)}`; + const attrValue = attributes[attr]; + let attrValueString; + + // If it is an object but doesn't have toString(), use Object.toString + if (Object(attrValue) === attrValue && !attrValue.toString) { + attrValueString = Object.prototype.toString.call(attrValue) + } else { + attrValueString = attrValue + ''; + } + + return `${attr}=${JSON.stringify(attrValueString)}`; }); } From b0399d369a854ce56d4866a69b0bbdeb41bac3c5 Mon Sep 17 00:00:00 2001 From: Daniel Ciao Date: Tue, 11 Jul 2017 14:55:57 -0700 Subject: [PATCH 4/5] Fix spacing From 8d34c7f5b9cadfdc5f78a9db88ced9bf4fd72bec Mon Sep 17 00:00:00 2001 From: Daniel Ciao Date: Tue, 11 Jul 2017 15:05:08 -0700 Subject: [PATCH 5/5] Fix spacing --- debug/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/index.js b/debug/index.js index 0a374144e2..fa02855308 100644 --- a/debug/index.js +++ b/debug/index.js @@ -75,7 +75,7 @@ if (process.env.NODE_ENV === 'development') { // If it is an object but doesn't have toString(), use Object.toString if (Object(attrValue) === attrValue && !attrValue.toString) { - attrValueString = Object.prototype.toString.call(attrValue) + attrValueString = Object.prototype.toString.call(attrValue); } else { attrValueString = attrValue + ''; }