瀏覽代碼

fix close all, avoid casting, and update test

Steven Silvester 8 年之前
父節點
當前提交
49a9238a62
共有 3 個文件被更改,包括 6 次插入6 次删除
  1. 2 2
      src/application/shell.ts
  2. 1 1
      src/docregistry/registry.ts
  3. 3 3
      test/src/toolbar/toolbar.spec.ts

+ 2 - 2
src/application/shell.ts

@@ -2,7 +2,7 @@
 // Distributed under the terms of the Modified BSD License.
 
 import {
-  each
+  each, toArray
 } from 'phosphor/lib/algorithm/iteration';
 
 import {
@@ -280,7 +280,7 @@ class ApplicationShell extends Widget {
    * Close all tracked widgets.
    */
   closeAll(): void {
-    each(this._dockPanel.widgets(), widget => { widget.close(); });
+    each(toArray(this._dockPanel.widgets()), widget => { widget.close(); });
   }
 
   private _topPanel: Panel;

+ 1 - 1
src/docregistry/registry.ts

@@ -400,7 +400,7 @@ class DocumentRegistry {
   widgetExtensions(widgetName: string): IIterator<DocumentRegistry.IWidgetExtension<Widget, DocumentRegistry.IModel>> {
     widgetName = widgetName.toLowerCase();
     if (!(widgetName in this._extenders)) {
-      return empty() as IIterator<DocumentRegistry.IWidgetExtension<Widget, DocumentRegistry.IModel>>;
+      return empty<DocumentRegistry.IWidgetExtension<Widget, DocumentRegistry.IModel>>();
     }
     return this._extenders[widgetName].iter();
   }

+ 3 - 3
test/src/toolbar/toolbar.spec.ts

@@ -128,13 +128,13 @@ describe('toolbar/toolbar', () => {
         widget.addItem('a', new Widget());
         let b = new Widget();
         widget.addItem('b', b);
-        expect(widget.removeItem(b)).to.be(1);
+        expect(widget.removeItem(b)).to.be(void 0);
       });
 
-      it('should return -1 if the widget is not in the toolbar', () => {
+      it('should be a no-op the widget is not in the toolbar', () => {
         let widget = new Toolbar();
         widget.addItem('a', new Widget());
-        expect(widget.removeItem(new Widget())).to.be(-1);
+        expect(widget.removeItem(new Widget())).to.be(void 0);
       });
 
     });