﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
11493	Selection#getRanges(true) overrides cached ranges	Michael Koza	Piotrek Koszuliński	"I was investigating an issue with a plugin that extended the link plugin (ckeditor_link Drupal project) and found a perhaps unintended side effect of this function. I noticed the plugin was using ""getRanges(true)"" to obtain the ranges instead of the ""getRanges()"" that link.js itself uses in the onOk defintion. For the most part this was working.

An except for an example:
{{{
[...]
definition.onOk = CKEDITOR.tools.override(definition.onOk, function(original) {
          return function() {
            var process = false;
            if ((this.getValueOf('info', 'linkType') == 'drupal') && !this._.selectedElement) {
              var ranges = editor.getSelection().getRanges(true);
              if ((ranges.length == 1) && ranges[0].collapsed) {
                process = true;
              }
            }
            original.call(this);
[...]
}}}

This works fine so long as it's not an image created by the new image2 image widget that the plugin is being applied to. All text and other items appeared to work correctly, but the {{{ getRanges(true) }}} call resulted in a length of 0 when used on a new image from the image widget. This is not the case on images created by the original image plugin.

After some investigation I tried the following:
I placed a {{{ console.log(editor.getSelection().getRanges(true)); }}} prior to the call of {{{ original.call(this);}}}

This resulted in breaking the standard functionality of the link plugin. I stepped through the process and found that the {{{ getRanges(true) }}} call modifies the original value and any subsequent calls to {{{ getRanges() }}} will result in the same value as the initial {{{ getRanges(true) }}} call. Is this the intended behaviour of the getRanges function with the optional parameter?

Since this only seems to cause an empty range selection on images created by the new image widget.


"	Bug	closed	Normal	CKEditor 4.3.3	Core : Selection		fixed		
