Esanders has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391553 )

Change subject: Update RangeFix 0.2.3 -> 0.2.6
......................................................................

Update RangeFix 0.2.3 -> 0.2.6

Change-Id: I04eba5b798ad9b8fb48f79fce19f28d0f3cc7c04
---
M lib/rangefix/LICENSE.txt
M lib/rangefix/README.md
M lib/rangefix/rangefix.js
3 files changed, 62 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/53/391553/1

diff --git a/lib/rangefix/LICENSE.txt b/lib/rangefix/LICENSE.txt
index 1f93858..8616a2f 100644
--- a/lib/rangefix/LICENSE.txt
+++ b/lib/rangefix/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2014-16 Ed Sanders under the terms
+Copyright (c) 2014-17 Ed Sanders under the terms
 of The MIT License (MIT), as follows:
 
 Permission is hereby granted, free of charge, to any person obtaining
diff --git a/lib/rangefix/README.md b/lib/rangefix/README.md
index 758be57..64ff80c 100644
--- a/lib/rangefix/README.md
+++ b/lib/rangefix/README.md
@@ -2,14 +2,45 @@
 
 In particular:
 
-* A Chrome bug which results in selections spanning multiple nodes returning 
rects for all the parents of the endContainer. See 
https://code.google.com/p/chromium/issues/detail?id=324437. This bug was fixed 
in Chrome 55.
-* A similar bug in Firefox but only triggered with images near the edge of a 
node.
-* A regression in Chrome 55 where images get no rectangle when they are 
wrapped in a node and you select across them.
-* A bug in IE (<=10) which results in scaled rectangles when using the 
browser's zoom feature.
+* Chrome <= 54: Selections spanning multiple nodes return rectangles for all 
the parents of the endContainer. See 
https://code.google.com/p/chromium/issues/detail?id=324437.
+* Chrome 55: Images get no rectangle when they are wrapped in a node and you 
select across them.
+* Safari: Similar to the Chrome <= 54 bug, but only triggered near the edge of 
a block node, or programmatically near an inline node.
+* Firefox: Similar to the Chrome <= 54 bug, but only triggered near the edge 
of a inline node
+* IE <= 10: Rectangles are incorrectly scaled when using the browser's zoom 
feature.
+
+There are no known issues in Chrome >= 56, Edge and IE >= 11. In these 
browsers the library will fall through to native behaviour.
+
+Install
+=======
+
+```bash
+$ npm install rangefix
+```
 
 Usage
 =====
-Include the rangefix.js library in your project.
+
+**CommonJS**
+
+```javascript
+var RangeFix = require( 'rangefix' );
+```
+
+**AMD**
+
+```javascript
+define( [ 'rangefix' ], function( Rangefix ) {
+       // ...
+} );
+```
+
+**Browser global**
+
+```html
+<script src="path/to/rangefix.js"></script>
+```
+
+**API**
 
 Replace instances of `Range.prototype.getClientRects`/`getBoundingClientRect` 
with `RangeFix.getClientRects`/`getBoundingClientRect`:
 
diff --git a/lib/rangefix/rangefix.js b/lib/rangefix/rangefix.js
index 0691b1c..7ad0b51 100644
--- a/lib/rangefix/rangefix.js
+++ b/lib/rangefix/rangefix.js
@@ -1,11 +1,22 @@
 /*!
- * RangeFix v0.2.3
+ * RangeFix v0.2.6
  * https://github.com/edg2s/rangefix
  *
  * Copyright 2014-17 Ed Sanders.
  * Released under the MIT license
  */
-( function () {
+( function ( root, factory ) {
+       if ( typeof define === 'function' && define.amd ) {
+               // AMD. Register as an anonymous module.
+               define( factory );
+       } else if ( typeof exports === 'object' && typeof exports.nodeName !== 
'string' ) {
+               // CommonJS
+               module.exports = factory();
+       } else {
+               // Browser globals
+               root.RangeFix = factory();
+       }
+}( this, function () {
 
        var broken,
                rangeFix = {};
@@ -31,7 +42,7 @@
         *                  'getBoundingClientRect' and 'ieZoom' indicating 
bugs are present
         *                  in these functions/browsers.
         */
-       function isBroken() {
+       rangeFix.isBroken = function () {
                var boundingRect, p, span, t1, t2, img, range, jscriptVersion;
 
                if ( broken === undefined ) {
@@ -60,10 +71,12 @@
                        broken.getClientRects = broken.getBoundingClientRect = 
range.getClientRects().length > 1;
 
                        if ( !broken.getClientRects ) {
-                               // A selection across a wrapped image should 
give a rect for that image
-                               // Regression in Chrome 55
+                               // Regression in Chrome 55:
+                               // A selection across a wrapped image should 
give a rect for that image.
+                               // In Chrome we get two rectangles, one for 
each text node. In working browsers
+                               // we get three or more, or in Edge we get one 
surrounding the text and the image.
                                range.setEnd( t2, 1 );
-                               broken.getClientRects = 
broken.getBoundingClientRect = range.getClientRects().length < 3;
+                               broken.getClientRects = 
broken.getBoundingClientRect = range.getClientRects().length === 2;
                        }
 
                        if ( !broken.getBoundingClientRect ) {
@@ -79,10 +92,10 @@
                        // Detect IE<=10 where zooming scaling is broken
                        // eslint-disable-next-line no-new-func
                        jscriptVersion = window.ActiveXObject && new Function( 
'/*@cc_on return @_jscript_version; @*/' )();
-                       broken.ieZoom = jscriptVersion && jscriptVersion <= 10;
+                       broken.ieZoom = !!jscriptVersion && jscriptVersion <= 
10;
                }
                return broken;
-       }
+       };
 
        /**
         * Compensate for the current zoom level in IE<=10
@@ -154,7 +167,7 @@
         */
        rangeFix.getClientRects = function ( range ) {
                var rects, endContainer, endOffset, partialRange,
-                       broken = isBroken();
+                       broken = this.isBroken();
 
                if ( broken.ieZoom ) {
                        return zoomFix( range.getClientRects() );
@@ -208,7 +221,7 @@
                }
 
                nativeBoundingRect = range.getBoundingClientRect();
-               broken = isBroken();
+               broken = this.isBroken();
 
                if ( broken.ieZoom ) {
                        return zoomFix( nativeBoundingRect );
@@ -251,7 +264,5 @@
                return boundingRect;
        };
 
-       // Expose
-       window.RangeFix = rangeFix;
-
-} )();
+       return rangeFix;
+} ) );

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

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

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

Reply via email to