Kaynağa Gözat

wip cleanup

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

+ 1 - 1
src/application/shell.ts

@@ -338,7 +338,7 @@ class ApplicationShell extends Widget {
    * Close all widgets in the main area.
    */
   closeAll(): void {
-    each(this._dockPanel.widgets(), widget => { widget.close(); });
+    each(toArray(this._dockPanel.widgets()), widget => { widget.close(); });
     this._save();
   }
 

+ 4 - 0
src/common/observablevector.ts

@@ -384,6 +384,10 @@ class ObservableVector<T> extends Vector<T> implements IObservableVector<T> {
    */
   pushBack(value: T): number {
     let num = super.pushBack(value);
+    // Bail if in the constructor.
+    if (!this._changed) {
+      return;
+    }
     this._changed.emit({
       type: 'add',
       oldIndex: -1,

+ 0 - 7
src/common/vector.ts

@@ -1,13 +1,6 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-/*-----------------------------------------------------------------------------
-| Copyright (c) 2014-2016, PhosphorJS Contributors
-|
-| Distributed under the terms of the BSD 3-Clause License.
-|
-| The full license is in the file LICENSE, distributed with this software.
-|----------------------------------------------------------------------------*/
 import {
   ArrayIterator, IIterator, IterableOrArrayLike, each
 } from '@phosphor/algorithm';

+ 2 - 2
test/src/application/shell.spec.ts

@@ -308,8 +308,8 @@ describe('ApplicationShell', () => {
       bar.id = 'bar';
       shell.addToMainArea(bar);
       shell.closeAll();
-      expect(foo.isAttached).to.be(false);
-      expect(bar.isAttached).to.be(false);
+      expect(foo.parent).to.be(null);
+      expect(bar.parent).to.be(null);
     });
 
   });

+ 1 - 1
test/src/docmanager/manager.spec.ts

@@ -292,7 +292,7 @@ describe('docmanager/manager', () => {
 
       it('should fail to find the context for the widget', () => {
         let widget = new Widget();
-        expect(manager.contextForWidget(widget)).to.be(void 0);
+        expect(manager.contextForWidget(widget)).to.be(null);
       });
 
     });

+ 2 - 2
test/src/docmanager/widgetmanager.spec.ts

@@ -190,8 +190,8 @@ describe('docmanager/widgetmanager', () => {
         expect(manager.contextForWidget(widget)).to.be(context);
       });
 
-      it('should return undefined if not tracked', () => {
-        expect(manager.contextForWidget(new Widget())).to.be(void 0);
+      it('should return null if not tracked', () => {
+        expect(manager.contextForWidget(new Widget())).to.be(null);
       });
 
     });