src/view/MainViewManager.js
function _destroyEditorIfNotNeeded(document) {
        if (!(document instanceof DocumentManager.Document)) {
            throw new Error("_destroyEditorIfUnneeded() should be passed a Document");
        }
        if (document._masterEditor) {
            // findPaneForDocument tries to locate the pane in which the document
            //  is either opened or will be opened (in the event that the document is
            //  in a working set but has yet to be opened) and then asks the pane
            //  to destroy the view if it doesn't need it anymore
            var pane = _findPaneForDocument(document);

            if (pane) {
                // let the pane deceide if it wants to destroy the view if it's no needed
                pane.destroyViewIfNotNeeded(document._masterEditor);
            } else {
                // in this case, the document isn't referenced at all so just destroy it
                document._masterEditor.destroy();
            }
        }
    }
function _destroyEditorIfNotNeeded(document) {
        if (!(document instanceof DocumentManager.Document)) {
            throw new Error("_destroyEditorIfUnneeded() should be passed a Document");
        }
        if (document._masterEditor) {
            // findPaneForDocument tries to locate the pane in which the document
            //  is either opened or will be opened (in the event that the document is
            //  in a working set but has yet to be opened) and then asks the pane
            //  to destroy the view if it doesn't need it anymore
            var pane = _findPaneForDocument(document);

            if (pane) {
                // let the pane deceide if it wants to destroy the view if it's no needed
                pane.destroyViewIfNotNeeded(document._masterEditor);
            } else {
                // in this case, the document isn't referenced at all so just destroy it
                document._masterEditor.destroy();
            }
        }
    }
function _destroyEditorIfNotNeeded ( document ) { if ( ! ( document instanceof DocumentManager . Document ) ) { throw new Error ( "_destroyEditorIfUnneeded() should be passed a Document" ) ; } if ( document . _masterEditor ) { // findPaneForDocument tries to locate the pane in which the document //  is either opened or will be opened (in the event that the document is //  in a working set but has yet to be opened) and then asks the pane //  to destroy the view if it doesn't need it anymore var pane = _findPaneForDocument ( document ) ; if ( pane ) { // let the pane deceide if it wants to destroy the view if it's no needed pane . destroyViewIfNotNeeded ( document . _masterEditor ) ; } else { // in this case, the document isn't referenced at all so just destroy it document . _masterEditor . destroy ( ) ; } } }
Destroys an editor object if a document is no longer referenced
@param {!Document} doc - document to destroy
Destroys an editor object if a document is no longer referenced