TheDJ has uploaded a new change for review. https://gerrit.wikimedia.org/r/133942
Change subject: jquery.textSelection: Don't throw errors on empty collections ...................................................................... jquery.textSelection: Don't throw errors on empty collections All jQuery functions just do nothing or return "empty" values when called on an empty collection (e.g. `$()`), the ones defined in this module should behave in the same way. This came to light when a change in WikiEditor combined with lousy coding caused this code path to be called, breaking various gadgets and extensions like SemanticForms. Bug: 64289 Change-Id: Ib97f47ef1d66420682bd429c9c12e66c3392e77d (cherry picked from commit 2828669dd40f63f60c2391b6d5ee30a3e255f3db) --- M resources/src/jquery/jquery.textSelection.js 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/42/133942/1 diff --git a/resources/src/jquery/jquery.textSelection.js b/resources/src/jquery/jquery.textSelection.js index 7262fe6..4540fb0 100644 --- a/resources/src/jquery/jquery.textSelection.js +++ b/resources/src/jquery/jquery.textSelection.js @@ -70,7 +70,7 @@ var retval, range, el = this.get( 0 ); - if ( $(el).is( ':hidden' ) ) { + if ( !el || $( el ).is( ':hidden' ) ) { retval = ''; } else if ( document.selection && document.selection.createRange ) { activateElementOnIE( el ); @@ -279,7 +279,7 @@ // Range containing text after the selection postRange; - if ( document.selection && document.selection.createRange ) { + if ( e && document.selection && document.selection.createRange ) { // IE doesn't properly report non-selected caret position through // the selection ranges when textarea isn't focused. This can // lead to saving a bogus empty selection, which then screws up @@ -349,7 +349,7 @@ } while ( ( !preFinished || !periFinished || !postFinished ) ); caretPos = rawPreText.replace( /\r\n/g, '\n' ).length; endPos = caretPos + rawPeriText.replace( /\r\n/g, '\n' ).length; - } else if ( e.selectionStart || e.selectionStart === 0 ) { + } else if ( e && ( e.selectionStart || e.selectionStart === 0 ) ) { // Firefox support caretPos = e.selectionStart; endPos = e.selectionEnd; -- To view, visit https://gerrit.wikimedia.org/r/133942 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib97f47ef1d66420682bd429c9c12e66c3392e77d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: REL1_23 Gerrit-Owner: TheDJ <hartman.w...@gmail.com> Gerrit-Reviewer: Bartosz DziewoĆski <matma....@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits