Comparing version 1.2.3 to 1.2.4
33
index.js
@@ -12,2 +12,3 @@ var domSerialize = require('serialize-dom') | ||
exports.apply = function(snapshot, ops) { | ||
snapshot = snapshot.cloneNode(true) | ||
unpackOps(ops) | ||
@@ -36,3 +37,3 @@ .forEach(function(op) { | ||
range = range.cloneRange() | ||
if(rootNode.contains(range.startContainer)) { | ||
if(rootNode.contains(range.startContainer) && range.startContainer.nodeValue) { | ||
var cs = Changeset.create() | ||
@@ -47,7 +48,6 @@ .retain(range.startOffset) | ||
var cursorOp = cursorOps[0] | ||
var length = countInitialRetains(cursorOp.diff) | ||
if(cursorOp.path === null) range.collapse(false) | ||
else range.setStart(nodeAt(cursorOp.path, rootNode), length) | ||
var start = nodeAt(cursorOp.path, rootNode) | ||
var startLength = countInitialRetains(cursorOp.diff) | ||
} | ||
if(rootNode.contains(range.endContainer)) { | ||
if(rootNode.contains(range.endContainer) && range.endContainer.nodeValue) { | ||
var cs = Changeset.create() | ||
@@ -62,7 +62,26 @@ .retain(range.endOffset) | ||
var cursorOp = cursorOps[0] | ||
var end = nodeAt(cursorOp.path, rootNode) | ||
var length = countInitialRetains(cursorOp.diff) | ||
if(cursorOp.path === null) range.collapse(true) | ||
else range.setEnd(nodeAt(cursorOp.path, rootNode), length) | ||
} | ||
try { | ||
if(!start) range.collapse(false) | ||
else range.setStart(start, length) | ||
if(!end) range.collapse(true) | ||
else range.setEnd(end, length) | ||
}catch(e) { | ||
} | ||
try { | ||
if(!end) range.collapse(true) | ||
else range.setEnd(end, length) | ||
if(!start) range.collapse(false) | ||
else range.setStart(start, length) | ||
}catch(e) { | ||
} | ||
return range | ||
@@ -69,0 +88,0 @@ } |
{ | ||
"name": "dom-ot", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "Operational transform library for DOM operations (conforms to shareJS' spec)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28151
704