Skip to content

Commit

Permalink
Merge pull request #211 from YSYoon/master
Browse files Browse the repository at this point in the history
Avoid calling getElementChecksum if not needed
  • Loading branch information
timdown committed Jun 29, 2014
2 parents 380cfe7 + d2e39ff commit ae7d613
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/js/modules/rangy-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,13 @@ rangy.createModule("Serializer", ["WrappedSelection"], function(api, module) {
rootNode = doc.documentElement;
}
var result = deserializeRegex.exec(serialized);
var checksum = result[4], rootNodeChecksum = getElementChecksum(rootNode);
if (checksum && checksum !== getElementChecksum(rootNode)) {
throw module.createError("deserializeRange(): checksums of serialized range root node (" + checksum +
var checksum = result[4];
if (checksum) {
var rootNodeChecksum = getElementChecksum(rootNode);
if (checksum !== rootNodeChecksum) {
throw module.createError("deserializeRange(): checksums of serialized range root node (" + checksum +
") and target root node (" + rootNodeChecksum + ") do not match");
}
}
var start = deserializePosition(result[1], rootNode, doc), end = deserializePosition(result[2], rootNode, doc);
var range = api.createRange(doc);
Expand Down

0 comments on commit ae7d613

Please sign in to comment.