rangy icon indicating copy to clipboard operation
rangy copied to clipboard

Rangy is throwing an error about Discontiguous Selection

Open robertleeplummerjr opened this issue 11 years ago • 9 comments

http://cl.ly/image/0M1h3n2E1p0q

robertleeplummerjr avatar Sep 09 '14 17:09 robertleeplummerjr

Which version of Rangy? I added a workaround and recent 1.3 releases on GitHub should not display this message.

There is no actual error; Chrome is just printing a warning to the console, so behaviour is not actually affected. It first showed up in (I think) Chrome 35 or 36. I disagree with their decision to implement it. See https://code.google.com/p/chromium/issues/detail?id=399791

For more background, here's an older bug: https://code.google.com/p/rangy/issues/detail?id=208

timdown avatar Sep 09 '14 23:09 timdown

Thanks for closing this and your description. Tim, your work is amazing.

robertleeplummerjr avatar Feb 11 '15 02:02 robertleeplummerjr

Also had this, will try rangy 1.3 soon

slorber avatar Jul 21 '15 16:07 slorber

Oups @timdown unfurtunatly I'm already 1.3.0 (not alpha)!

The bug appeared very recently for me, probably because of a Chrome update?

I'm using Chrome Version 37.0.2062.120 (64-bit) on Ubuntu 12.04

slorber avatar Jul 21 '15 16:07 slorber

@slorber Can you give me some example code to reproduce the issue?

timdown avatar Jul 21 '15 23:07 timdown

hahaha @timdown I understand the problem.

This is your code:

                        // Doing the original feature test here in Chrome 36 (and presumably later versions) prints a
                        // console error of "Discontiguous selection is not supported." that cannot be suppressed. There's
                        // nothing we can do about this while retaining the feature test so we have to resort to a browser
                        // sniff. I'm not happy about it. See
                        // https://code.google.com/p/chromium/issues/detail?id=399791
                        var chromeMatch = window.navigator.appVersion.match(/Chrome\/(.*?) /);
                        if (chromeMatch && parseInt(chromeMatch[1]) >= 36) {
                            selectionSupportsMultipleRanges = false;

But it does not work when we use Chrome's mobile emulator because:

window.navigator.appVersion="5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53"

So I guess there's nothing you can do here (?)

slorber avatar Jul 22 '15 10:07 slorber

Well, there you go. This is why I never normally use user agent sniffs and another reason why this warning message in Chrome is a bad idea. Now I'm reduced to scrabbling around for a better user agent sniff. Grrrrr.

I suppose an alternative is to just check window.navigator.appVersion for Firefox/Gecko, which is the only browser/rendering engine to support multiple ranges, but this is all just floundering around in crazy nonsense land.

timdown avatar Jul 22 '15 11:07 timdown

I don't know, choose whatever you want but this does not impact me: the emulator is only used for dev env so the error won't be in production

slorber avatar Jul 22 '15 11:07 slorber

@timdown Even with the emulator enabled, Chrome still reports 'Google Inc.' in window.navigator.vendor. What would you think of broadening the check to just see if the app version contains 'Chrome' or the vendor contains 'Google'?

Ghazgkull avatar Feb 02 '16 00:02 Ghazgkull