Browse Source

When timing metadata changes, ensure metadata.changed fires

This bug was caused by updating the object in place instead of
copying before each change. With the former, metadata.changed does
not signal.
Marc Udoff 5 years ago
parent
commit
417f7165d2
1 changed files with 8 additions and 2 deletions
  1. 8 2
      packages/cells/src/widget.ts

+ 8 - 2
packages/cells/src/widget.ts

@@ -1083,7 +1083,10 @@ export namespace CodeCell {
           if (!value) {
             return;
           }
-          const timingInfo: any = model.metadata.get('execution') || {};
+          const timingInfo: any = Object.assign(
+            {},
+            model.metadata.get('execution')
+          );
           timingInfo[`iopub.${label}`] = value;
           model.metadata.set('execution', timingInfo);
           return true;
@@ -1096,7 +1099,10 @@ export namespace CodeCell {
       model.executionCount = msg.content.execution_count;
       const started = msg.metadata.started as string;
       if (recordTiming && started) {
-        const timingInfo = (model.metadata.get('execution') as any) || {};
+        const timingInfo = Object.assign(
+          {},
+          model.metadata.get('execution') as any
+        );
         if (started) {
           timingInfo['shell.execute_reply.started'] = started;
         }