/* globals MutationObserver */
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
- if(documentElement.DocumentTextElement.isContentContainer(mutation.target)) {
+ if(canvas.dom[0].contains(mutation.target) && documentElement.DocumentTextElement.isContentContainer(mutation.target)) {
observer.disconnect();
if(mutation.target.data === '') {
mutation.target.data = utils.unicode.ZWS;
if(position.element) {
this._moveCaretToTextElement(position.element, position.offset);
}
- },
-
- toggleGrid: function() {
- this.rootWrapper.toggleClass('grid-on');
- this.trigger('changed');
- },
- isGridToggled: function() {
- return this.rootWrapper.hasClass('grid-on');
}
});
return doc.createFragment(doc.CaretFragment, {node: anchorNode, offset: this.nativeSelection.anchorOffset});
}
if(this.type === 'textSelection') {
+ if(!anchorNode || !focusNode) {
+ return;
+ }
if(anchorNode.isSiblingOf(focusNode)) {
return doc.createFragment(doc.TextRangeFragment, {
node1: anchorNode,