Prechádzať zdrojové kódy

Merge pull request #2957 from blink1073/fix-docmodel-tojson

Fix DocumentModel initialization
Afshin Darian 7 rokov pred
rodič
commit
b1761ba17c
1 zmenil súbory, kde vykonal 4 pridanie a 2 odobranie
  1. 4 2
      packages/docregistry/src/default.ts

+ 4 - 2
packages/docregistry/src/default.ts

@@ -141,7 +141,7 @@ class DocumentModel extends CodeEditor.Model implements DocumentRegistry.ICodeMo
    * Serialize the model to JSON.
    */
   toJSON(): JSONValue {
-    return JSON.parse(this.value.text);
+    return JSON.parse(this.value.text || 'null');
   }
 
   /**
@@ -487,7 +487,9 @@ class MimeDocument extends Widget implements DocumentRegistry.IReadyWidget {
    * Handle an `update-request` message to the widget.
    */
   protected onUpdateRequest(msg: Message): void {
-    this._render();
+    if (this._context.isReady) {
+      this._render();
+    }
   }
 
   /**