From c09fc16d54925941b96cc127c6c958cf8f706ab8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 16 Jun 2011 23:04:26 +0000 Subject: [PATCH] Followup to r90240: clean up some stray code, check for an error condition --- modules/jquery.codeEditor.js | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/modules/jquery.codeEditor.js b/modules/jquery.codeEditor.js index 9fdad7f2..da3c63df 100644 --- a/modules/jquery.codeEditor.js +++ b/modules/jquery.codeEditor.js @@ -232,8 +232,10 @@ var saveAndExtend = function( base, extended ) { base[name] = function() { if (context.codeEditorActive) { return func.apply(this, arguments); - } else { + } else if (orig) { return orig.apply(this, arguments); + } else { + throw new Error('CodeEditor: no original function to call for ' + name); } } } else { @@ -244,34 +246,18 @@ var saveAndExtend = function( base, extended ) { saveAndExtend( context.fn, { 'saveCursorAndScrollTop': function() { - if ( context.codeEditor ) { - // Stub out textarea behavior - return; - } else { - context.codeEditorStubs.saveCursorAndScrollTop.apply(this); - } + // Stub out textarea behavior + return; }, 'restoreCursorAndScrollTop': function() { - if ( context.codeEditor ) { - // Stub out textarea behavior - return; - } else { - context.codeEditorStubs.saveCursorAndScrollTop.apply(this); - } + // Stub out textarea behavior + return; }, 'saveSelection': function() { - if ( context.codeEditor ) { - mw.log('codeEditor stub function saveSelection called'); - } else { - context.codeEditorStubs.saveCursorAndScrollTop.apply(this); - } + mw.log('codeEditor stub function saveSelection called'); }, 'restoreSelection': function() { - if ( context.codeEditor ) { - mw.log('codeEditor stub function restoreSelection called'); - } else { - context.codeEditorStubs.saveCursorAndScrollTop.apply(this); - } + mw.log('codeEditor stub function restoreSelection called'); }, /* Needed for search/replace */