diff --git a/package.json b/package.json index ed8a5ba..66155a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "epubjs", - "version": "0.3.55", + "version": "0.3.56", "description": "Parse and Render Epubs", "main": "lib/index.js", "module": "src/index.js", diff --git a/src/annotations.js b/src/annotations.js index 475cb67..0adf060 100644 --- a/src/annotations.js +++ b/src/annotations.js @@ -61,7 +61,7 @@ class Annotations { let views = this.rendition.views(); - views.each( (view) => { + views.forEach( (view) => { if (annotation.sectionIndex === view.index) { annotation.attach(view); } @@ -75,12 +75,13 @@ class Annotations { if (hash in this._annotations) { let annotation = this._annotations[hash]; - if (annotation.type !== type) { + + if (type && annotation.type !== type) { return; } let views = this.rendition.views(); - views.each( (view) => { + views.forEach( (view) => { this._removeFromAnnotationBySectionIndex(annotation.sectionIndex, hash); if (annotation.sectionIndex === view.index) { annotation.detach(view); diff --git a/src/epubcfi.js b/src/epubcfi.js index 23d63f1..88de1be 100644 --- a/src/epubcfi.js +++ b/src/epubcfi.js @@ -928,7 +928,7 @@ class EpubCFI { range.setStart(missed.container, missed.offset); } } else { - console.log("NO START"); + console.log("No startContainer found for", this.toString()); // No start found return null; } diff --git a/src/managers/continuous/index.js b/src/managers/continuous/index.js index b219963..42e8395 100644 --- a/src/managers/continuous/index.js +++ b/src/managers/continuous/index.js @@ -532,7 +532,7 @@ class ContinuousViewManager extends DefaultViewManager { this.overflow = this.settings.overflow; } - // this.views.each(function(view){ + // this.views.forEach(function(view){ // view.setAxis(axis); // }); diff --git a/src/managers/default/index.js b/src/managers/default/index.js index c821a28..94e6f95 100644 --- a/src/managers/default/index.js +++ b/src/managers/default/index.js @@ -733,7 +733,7 @@ class DefaultViewManager { if(this.views) { - this.views.each(function(view){ + this.views.forEach(function(view){ if (view) { view.setLayout(layout); } @@ -757,7 +757,7 @@ class DefaultViewManager { } else { this.overflow = this.settings.overflow; } - // this.views.each(function(view){ + // this.views.forEach(function(view){ // view.setAxis(axis); // }); @@ -770,7 +770,7 @@ class DefaultViewManager { if (!this.views) { return contents; } - this.views.each(function(view){ + this.views.forEach(function(view){ const viewContents = view && view.contents; if (viewContents) { contents.push(viewContents); diff --git a/src/managers/helpers/views.js b/src/managers/helpers/views.js index 7c8ba1b..dc0a465 100644 --- a/src/managers/helpers/views.js +++ b/src/managers/helpers/views.js @@ -89,7 +89,7 @@ class Views { // Iterators - each() { + forEach() { return this._views.forEach.apply(this._views, arguments); } diff --git a/src/managers/views/iframe.js b/src/managers/views/iframe.js index 7267094..96a9c9b 100644 --- a/src/managers/views/iframe.js +++ b/src/managers/views/iframe.js @@ -570,7 +570,9 @@ class IframeView { } let range = this.contents.range(cfiRange); - + if (!range) { + return; + } let container = range.commonAncestorContainer; let parent = (container.nodeType === 1) ? container : container.parentNode;