Rangy is throwing an error about Discontiguous Selection
http://cl.ly/image/0M1h3n2E1p0q
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
Thanks for closing this and your description. Tim, your work is amazing.
Also had this, will try rangy 1.3 soon
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 Can you give me some example code to reproduce the issue?
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 (?)
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.
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
@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'?