Kaynağa Gözat

Fix uses of createNode

Steven Silvester 8 yıl önce
ebeveyn
işleme
b95249e8f9

+ 9 - 8
src/notebook/notebook/toolbar.ts

@@ -104,18 +104,11 @@ class NotebookToolbar extends Widget {
  */
 export
 class ToolbarButton extends Widget {
-  /**
-   * Create the node for the toolbar button.
-   */
-  static createNode(): HTMLElement {
-    return document.createElement('span');
-  }
-
   /**
    * Construct a new toolbar button.
    */
   constructor(options: ToolbarButton.IOptions = {}) {
-    super();
+    super({ node: Private.createNode() });
     options = options || {};
     this.addClass(TOOLBAR_BUTTON);
     this._onClick = options.onClick;
@@ -224,4 +217,12 @@ namespace Private {
    */
   export
   const nameProperty = new AttachedProperty<Widget, string>({ name: 'name' });
+
+  /**
+   * Create the node for the toolbar button.
+   */
+  export
+  function createNode(): HTMLElement {
+    return document.createElement('span');
+  }
 }

+ 22 - 14
src/notebook/output-area/widget.ts

@@ -852,24 +852,11 @@ class OutputWidget extends Widget {
  * A widget that handles stdin requests from the kernel.
  */
  class InputWidget extends Widget {
-  /**
-   * Create the node for an InputWidget.
-   */
-  static createNode(): HTMLElement {
-    let node = document.createElement('div');
-    let prompt = document.createElement('span');
-    prompt.className = STDIN_PROMPT_CLASS;
-    let input = document.createElement('input');
-    input.className = STDIN_INPUT_CLASS;
-    node.appendChild(prompt);
-    node.appendChild(input);
-    return node;
-  }
   /**
    * Construct a new input widget.
    */
   constructor(request: OutputAreaModel.IInputRequest) {
-    super();
+    super({ node: Private.createInputWidgetNode() });
     this.addClass(STDIN_CLASS);
     let text = this.node.firstChild as HTMLElement;
     text.textContent = request.prompt;
@@ -951,3 +938,24 @@ namespace OutputWidget {
 // Define the signals for the `OutputAreaWidget` class.
 defineSignal(OutputAreaWidget.prototype, 'modelChanged');
 defineSignal(OutputAreaWidget.prototype, 'modelDisposed');
+
+
+/**
+ * A namespace for private data.
+ */
+namespace Private {
+  /**
+   * Create the node for an InputWidget.
+   */
+  export
+  function createInputWidgetNode(): HTMLElement {
+    let node = document.createElement('div');
+    let prompt = document.createElement('span');
+    prompt.className = STDIN_PROMPT_CLASS;
+    let input = document.createElement('input');
+    input.className = STDIN_INPUT_CLASS;
+    node.appendChild(prompt);
+    node.appendChild(input);
+    return node;
+  }
+}