In Development
Last Updated: 11 Nov 2025 09:31 by ADMIN
Scheduled for 2026 Q1 (Feb)
Narendran
Created on: 11 Nov 2025 09:26
Category: Editor
Type: Bug Report
0
Uncaught TypeError: Failed to execute 'setStart' on 'Range': parameter 1 is not of type 'Node'.

Steps to Reproduce

  1. Open a page containing RadEditor with some content in it
  2. In Design mode, select all text (Ctrl+A)
  3. Delete the selected text
  4. Switch to HTML mode
  5. Switch back to Design mode
  6. Press Ctrl+Z (Undo) a couple of times.
Current Result
  • A JavaScript error is thrown in the browser console
  • The undo operation fails to restore the deleted content
  • Error occurs in _updateBrowserRangeStart method when calling this.range.setStart(e, t)

Expected Result

  • The undo operation should work without errors
  • The previously deleted text should be restored
  • No JavaScript errors should appear in the console
1 comment
ADMIN
Rumen
Posted on: 11 Nov 2025 09:30

Hi Narendran,

Thank you for reporting this error.

The issue is scheduled to be resolved in the release immediately following the Q4 2025 update.

In the meantime, you can apply the following code override as a temporary workaround:

<script>
    var $E = Telerik.Web.UI.Editor;
    var startOffsetAttr = '_startoffset';
    var endOffsetAttr = '_endoffset';
    var startIndex = '_startindex';
    var endIndex = '_endindex';

    $E.DomRangeMemento.prototype =
    {
        restoreToRange: function (r) {
            this.compensateOffsetInIE9();

            try {
                this.restoreStart(r);

                if (this.endOffset === false) { r.setEndBefore(this.endContainer); } else if (this.endOffset == 'outside') { r.setEnd(this.endContainer, Math.max(1, this.endContainer.childNodes.length - 1)); } else { r.setEnd(this.endContainer, this.endOffset); }


                this.restoreStart(r);

                if (this.collapsed) { r.collapse(); }

                r.select();
            } catch (ex) {
                // Handle errors when nodes are detached from DOM after mode switching
            }
        },

        restoreStart: function (range) {
            try {
                if (this.startOffset === false) { range.setStartBefore(this.startContainer); } else { range.setStart(this.startContainer, this.startOffset); }
            } catch (ex) {
                // Silently handle errors when start container is detached
            }
        },

        compensateOffsetInIE9: function () { // IE9 has the nasty bug of moving the range selection with one character to the right
            if (!$telerik.isIE9) { return; }

            if (this.beginsWithWhitespace(this.startContainer)) { this.startOffset++; }

            if (this.beginsWithWhitespace(this.endContainer)) { this.endOffset++; }
        },
        beginsWithWhitespace: function (node) {
            return utils.isTextNode(node) && /^\s/.test(node.nodeValue);
        }
    };

    $E.RangeHolder.prototype._setRangeEdge = function (range, marker, toStart) {
        var offsetKey = toStart ? startOffsetAttr : endOffsetAttr;
        var offsetFn = toStart ? 'setStart' : 'setEnd';
        var indexAttr = toStart ? startIndex : endIndex;
        var index = parseInt(marker.getAttribute(indexAttr), 10);
        var offset = parseInt(marker.getAttribute(offsetKey), 10);

        if (!isNaN(offset) && !isNaN(index)) {
            var node = marker.childNodes[index];
            // Validate that the node exists and is connected to the DOM
            if (node && node.nodeType && node.ownerDocument && node.ownerDocument.contains(node)) {
                range[offsetFn](node, offset);
            }
        }
    }
</script>

<telerik:RadEditor
    RenderMode="Lightweight"
    runat="server"
    ID="RadEditor1">
    <Content>
        <br />
        line 1<br />
        line 2<br />
        line 3<br />
    </Content>
</telerik:RadEditor>

Regards,
Rumen
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources