From 7c7d1f961c0ba4d67d645ddc546faa68f1969937 Mon Sep 17 00:00:00 2001 From: Ivan De Marino Date: Thu, 18 Oct 2012 22:51:25 +0100 Subject: [PATCH] Adding "date" detection to `detectType` Addresses [Issue #800](http://code.google.com/p/phantomjs/issues/detail?id=800) --- src/bootstrap.js | 2 ++ src/modules/webpage.js | 1 + 2 files changed, 3 insertions(+) diff --git a/src/bootstrap.js b/src/bootstrap.js index 34cb24d3..6106f610 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -303,6 +303,8 @@ window.detectType = function (value) { s = 'array'; } else if (value instanceof RegExp) { s = 'regexp'; + } else if (value instanceof Date) { + s = 'date'; } } else { s = 'null'; diff --git a/src/modules/webpage.js b/src/modules/webpage.js index f255053e..e939e668 100644 --- a/src/modules/webpage.js +++ b/src/modules/webpage.js @@ -282,6 +282,7 @@ function decorateNewPage(opts, page) { switch (argType) { case "object": //< for type "object" case "array": //< for type "array" + case "date": //< for type "date" str += "JSON.parse(" + JSON.stringify(JSON.stringify(arg)) + ")," break; case "string": //< for type "string"