timdown / rangy

A cross-browser JavaScript range and selection library.
MIT License
2.24k stars 368 forks source link

canDeserializeRange() always returns false #394

Open jonbrooks opened 8 years ago

jonbrooks commented 8 years ago

In my experience, canDeserializeRange() returns false even when the dom hasn't changed. Looking at it in the debugger, it looks like an off-by-one error in this code in rangy-serializer.js:

    var result = deserializeRegex.exec(serialized);
    var checksum = result[3];
    return !checksum || checksum === getElementChecksum(rootNode);

The deserializeRegex has 4 capturing parentheses, so the item we're interested in is result[4], not result[3]. result[3] includes the brackets, so the test 1234 === '{1234}' fails.

srsudar commented 4 years ago

I see the same thing, even on the serializer demo page.