From 4b6c753f3ff5dca9c6d1b274f6f3839957454d56 Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Thu, 13 Nov 2014 15:37:56 +0000 Subject: [PATCH 1/3] Dates are JavaScript objects, and _pack_models returns an empty object --- IPython/html/static/widgets/js/widget.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IPython/html/static/widgets/js/widget.js b/IPython/html/static/widgets/js/widget.js index 34822bd75..a3df7e0eb 100644 --- a/IPython/html/static/widgets/js/widget.js +++ b/IPython/html/static/widgets/js/widget.js @@ -236,7 +236,8 @@ define(["widgets/js/manager", packed.push(that._pack_models(sub_value)); }); return packed; - + } else if (value instanceof Date) { + return value; } else if (value instanceof Object) { packed = {}; _.each(value, function(sub_value, key) { From 604d0bb6663953959aafac023720b0468a20b034 Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Thu, 13 Nov 2014 15:42:31 +0000 Subject: [PATCH 2/3] A String is an object --- IPython/html/static/widgets/js/widget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IPython/html/static/widgets/js/widget.js b/IPython/html/static/widgets/js/widget.js index a3df7e0eb..ea5c062c5 100644 --- a/IPython/html/static/widgets/js/widget.js +++ b/IPython/html/static/widgets/js/widget.js @@ -236,7 +236,7 @@ define(["widgets/js/manager", packed.push(that._pack_models(sub_value)); }); return packed; - } else if (value instanceof Date) { + } else if (value instanceof Date || value instanceof String) { return value; } else if (value instanceof Object) { packed = {}; From 2a026ed45b74aaaab9e18bcd3099629962c2da92 Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Thu, 13 Nov 2014 18:50:21 +0000 Subject: [PATCH 3/3] Test packing/unpacking instances of Date and String --- IPython/html/tests/widgets/widget.js | 1 + 1 file changed, 1 insertion(+) diff --git a/IPython/html/tests/widgets/widget.js b/IPython/html/tests/widgets/widget.js index ef8b26305..e79a91544 100644 --- a/IPython/html/tests/widgets/widget.js +++ b/IPython/html/tests/widgets/widget.js @@ -81,6 +81,7 @@ casper.notebook_test(function () { test_packing([1, false]); test_packing([1, false, {a: 'hi'}]); test_packing([1, false, ['hi']]); + test_packing([String('hi'), Date("Thu Nov 13 2014 13:46:21 GMT-0500")]) // Test multi-set, single touch code. First create a custom widget. this.evaluate(function() {