From 0f34affc35ebe81d806ad1fcdaed61f4ed2dc6cd Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Wed, 27 Nov 2013 09:46:23 -0800 Subject: [PATCH] Dont send add and remove class calls if no comm exists --- IPython/html/widgets/widget.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/IPython/html/widgets/widget.py b/IPython/html/widgets/widget.py index facf651c6..2e8fb05a0 100644 --- a/IPython/html/widgets/widget.py +++ b/IPython/html/widgets/widget.py @@ -304,9 +304,10 @@ class Widget(LoggingConfigurable): JQuery selector to select the DOM element(s) that the class(es) will be added to. """ - self._comm.send({"method": "add_class", - "class_list": class_name, - "selector": selector}) + if self._comm is not None: + self._comm.send({"method": "add_class", + "class_list": class_name, + "selector": selector}) def remove_class(self, class_name, selector=""): @@ -321,9 +322,10 @@ class Widget(LoggingConfigurable): JQuery selector to select the DOM element(s) that the class(es) will be removed from. """ - self._comm.send({"method": "remove_class", - "class_list": class_name, - "selector": selector}) + if self._comm is not None: + self._comm.send({"method": "remove_class", + "class_list": class_name, + "selector": selector}) def send(self, content):