selection.getRangeAt(0) sometimes returns null for non-empty selections

Fixed, not yet flighted Issue #7321753


Apr 24, 2016
This issue is public.
Found in
  • Microsoft Edge
Found in build #
Reported by 2 people

Sign in to watch or report this issue.

Steps to reproduce

selection.getRangeAt(0) sometimes returns null for non-empty selections. To reproduce, open,console or run the code at the end of the report in a console. The result is that range.setStart throws because range is null; this only happens in Edge 12 & 13; Firefox 45, Chrome 50, Safari 9, IE 10-11 work fine.
var selection = window.getSelection();
var elem = document.createElement(‘div’); = 'container’;
elem.innerHTML = [
'<div class="div0">div0 </div>’,
'<div class="div1">div1 <span>span1 </span></div>’,
'<div class="div2">div2</div>’,
var nodes = elem.childNodes;
var range = selection.getRangeAt(0);
console.log(selection + ‘’);
console.log(range + ‘’);
range.setStart(nodes[1].childNodes[0], 2);
range.setEnd(nodes[2].childNodes[0], 1);
console.log(range + ‘’);


0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Assigned To to “Amit J.”

      Changed Status to “Confirmed”

      Changed Assigned To from “Amit J.” to “Anand A.”

      Changed Status from “Confirmed” to “In code review”

      Changed Status from “In code review” to “In progress”

      Changed Status from “In progress” to “Fixed, not yet flighted”

    • Issue is fixed and will be available in the upcoming Windows Insider build (Sorry about the delay in getting back to you on this). Should be fixed in builds 14357 and higher.

      All the best,
      The MS Edge Team

    You need to sign in to your Microsoft account to add a comment.

    Sign in