This allows client code to refresh Fragment object to reference
proper node instances after some potentially invalidating
changes to a document has been made while the logical structure
of the document is known to be the same.
An example of such a scenario would be a fragment instance created
before performing a transaction that was later undone using full
document reload.
var NodeFragment = function(document, params) {
Fragment.call(this, document);
this.node = params.node;
var NodeFragment = function(document, params) {
Fragment.call(this, document);
this.node = params.node;
+ this.nodePath = params.node.getPath();
};
NodeFragment.prototype = Object.create(Fragment.prototype);
$.extend(NodeFragment.prototype, {
isValid: function() {
return this.document.containsNode(this.node);
};
NodeFragment.prototype = Object.create(Fragment.prototype);
$.extend(NodeFragment.prototype, {
isValid: function() {
return this.document.containsNode(this.node);
+ },
+ restoreFromPaths: function() {
+ this.node = this.document.getNodeByPath(this.nodePath);
this[prefix + 'Node'] = params['node'+(idx+1)];
}.bind(this));
}
this[prefix + 'Node'] = params['node'+(idx+1)];
}.bind(this));
}
+ this.startNodePath = this.startNode.getPath();
+ this.endNodePath = this.endNode.getPath();
};
RangeFragment.prototype = Object.create(Fragment.prototype);
$.extend(RangeFragment.prototype, {
isValid: function() {
return this.document.containsNode(this.startNode) && this.document.containsNode(this.endNode);
},
};
RangeFragment.prototype = Object.create(Fragment.prototype);
$.extend(RangeFragment.prototype, {
isValid: function() {
return this.document.containsNode(this.startNode) && this.document.containsNode(this.endNode);
},
+ restoreFromPaths: function() {
+ this.startNode = this.document.getNodeByPath(this.startNodePath);
+ this.endNode = this.document.getNodeByPath(this.endNodePath);
+ },
hasSiblingBoundries: function() {
return this.isValid() && this.startNode.isSiblingOf(this.endNode);
},
hasSiblingBoundries: function() {
return this.isValid() && this.startNode.isSiblingOf(this.endNode);
},