From 35e611369ba9b0df744ecbc80ca36492df5a1a3e Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 22 Jul 2014 15:21:29 -0700 Subject: [PATCH] Followup 3dd1a996: don't try to switch to source mode when surface is torn down If you saved a change, then clicked Edit source, you'd get a JS error. Change-Id: I589f9edb354afcd47d5c42ef9a6c73d49218b044 --- modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index 387121eb78..fe692e2219 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -1112,10 +1112,12 @@ ve.init.mw.ViewPageTarget.prototype.setupSkinTabs = function () { .click( this.onViewTabClick.bind( this ) ); $( '#ca-viewsource, #ca-edit' ).click( function ( e ) { - viewPageTarget.editSource(); + if ( viewPageTarget.surface && !viewPageTarget.deactivating ) { + viewPageTarget.editSource(); - if ( viewPageTarget.surface.getModel().hasBeenModified() ) { - e.preventDefault(); + if ( viewPageTarget.surface.getModel().hasBeenModified() ) { + e.preventDefault(); + } } } ); }