Catrope has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/165539

Change subject: Followup b8d8a5b: fix getNativeRange() in null selection case
......................................................................

Followup b8d8a5b: fix getNativeRange() in null selection case

Invoking getNativeRange( someRange ) should work, even if
the selection is null. Only when the range argument is also
null should a null selection cause it to fail.

b8d8a5b broke this by unconditionally returning null if the
selection was null. This commit restores the original behavior.

Change-Id: I12dfa1d21e75b8d12a71b644b7ce1b4db2abfec5
---
M src/ce/ve.ce.Surface.js
1 file changed, 5 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/39/165539/1

diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 502a405..d88da85 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -2451,14 +2451,15 @@
        var nativeRange, rangeSelection,
                selection = this.getModel().getSelection();
 
-       if ( !( selection instanceof ve.dm.LinearSelection ) ) {
-               return null;
-       }
-       if ( range && selection.getRange().equalsSelection( range ) ) {
+       if ( range && selection instanceof ve.dm.LinearSelection && 
selection.getRange().equalsSelection( range ) ) {
                // Range requested is equivalent to native selection so reset
                range = null;
        }
        if ( !range ) {
+               // Use native range, unless selection is null
+               if ( !( selection instanceof ve.dm.LinearSelection ) ) {
+                       return null;
+               }
                if ( this.nativeSelection.rangeCount > 0 ) {
                        try {
                                return this.nativeSelection.getRangeAt( 0 );

-- 
To view, visit https://gerrit.wikimedia.org/r/165539
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12dfa1d21e75b8d12a71b644b7ce1b4db2abfec5
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to