Skip to content

Commit

Permalink
Change REPLConsole.session to store only the latest single session
Browse files Browse the repository at this point in the history
Make a change of it to store only the latest single session,
since the current way does not work properly after closing the console element.

* Rename to `REPLConsole.currentSession`
* Move into `REPLConsole#install()`
  • Loading branch information
sh19910711 committed Jun 23, 2015
1 parent 172fc00 commit 9e3c107
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 6 additions & 3 deletions lib/web_console/templates/console.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ REPLConsole.prototype.install = function(container) {
findChild(container, 'resizer').addEventListener('mousedown', resizeContainer);
findChild(consoleActions, 'close-button').addEventListener('click', closeContainer);
consoleOuter.addEventListener('DOMNodeInserted', shiftConsoleActions);

REPLConsole.currentSession = this;
};

// Add CSS styles dynamically. This probably doesnt work for IE <8.
Expand Down Expand Up @@ -409,12 +411,13 @@ REPLConsole.installInto = function(id) {
});

replConsole.install(consoleElement);
REPLConsole.session[remotePath] = replConsole;
return replConsole;
};

// Store instances with the remote paths
REPLConsole.session = {};
// This is to store the latest single session, and the stored session
// is updated by the REPLConsole#install() method.
// It allows to operate the current session from the other scripts.
REPLConsole.currentSession = null;

// DOM helpers
function hasClass(el, className) {
Expand Down
6 changes: 1 addition & 5 deletions lib/web_console/templates/error_page.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ for (var i = 0; i < traceFrames.length; i++) {
}

function changeBinding(frameId, callback) {
var consoleElement = document.getElementById('console');
if (! consoleElement) { return; }
var remotePath = consoleElement.dataset.remotePath;
var session = REPLConsole.session[remotePath];
session.switchBindingTo(frameId, callback);
REPLConsole.currentSession.switchBindingTo(frameId, callback);
}

function changeSourceExtract(frameId) {
Expand Down

0 comments on commit 9e3c107

Please sign in to comment.