jenkins-bot has submitted this change and it was merged.
Change subject: TextInputWidget: Prevent uncaught errors when using
#selectRange in IE
......................................................................
TextInputWidget: Prevent uncaught errors when using #selectRange in IE
Bug: T128854
Change-Id: I0969d1070ff789821fce4c07d48ec95422048b2b
---
M src/widgets/TextInputWidget.js
1 file changed, 10 insertions(+), 1 deletion(-)
Approvals:
Bartosz Dziewoński: Looks good to me, approved
Jforrester: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index 0b48240..636f7ea 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -526,7 +526,16 @@
this.focus();
- input.setSelectionRange( start, end, isBackwards ? 'backward' :
'forward' );
+ try {
+ input.setSelectionRange( start, end, isBackwards ? 'backward' :
'forward' );
+ } catch ( e ) {
+ // IE throws an exception if you call setSelectionRange on a
unattached DOM node.
+ // Rather than expensively check if the input is attached every
time, just check
+ // if it was the cause of an error being thrown. If not,
rethrow the error.
+ if ( this.getElementDocument().body.contains( input ) ) {
+ throw e;
+ }
+ }
return this;
};
--
To view, visit https://gerrit.wikimedia.org/r/275281
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0969d1070ff789821fce4c07d48ec95422048b2b
Gerrit-PatchSet: 2
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits