1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

Moved code to not break test cases.

This commit is contained in:
Tushar Dudani 2019-02-10 22:53:34 +05:30
parent e323b9d879
commit 3a0f10195b
2 changed files with 11 additions and 11 deletions

View file

@ -574,6 +574,17 @@ class Contents {
if(this.epubcfi.isCfiString(target)) {
let range = new EpubCFI(target).toRange(this.document, ignoreClass);
try {
if (!range.endContainer) {
// If the end for the range is not set, it results in collapsed becoming
// true. This in turn leads to inconsistent behaviour when calling
// getBoundingRect. Wrong bounds lead to the wrong page being displayed.
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15684911/
range.setEnd(range.startContainer, range.startContainer.textContent.length);
}
} catch (e) {
console.error("setting end offset to start container length failed", e);
}
if(range) {
if (range.startContainer.nodeType === Node.ELEMENT_NODE) {

View file

@ -968,17 +968,6 @@ class EpubCFI {
missed = this.fixMiss(startSteps, start.terminal.offset, doc, needsIgnoring ? ignoreClass : null);
range.setStart(missed.container, missed.offset);
}
try {
if (!endContainer) {
// If the end for the range is not set, it results in collapsed becoming
// true. This in turn leads to inconsistent behaviour when calling
// getBoundingRect. Wrong bounds lead to the wrong page being displayed.
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15684911/
range.setEnd(startContainer, range.startContainer.textContent.length);
}
} catch (e) {
console.error("setting end offset to start container length failed", e);
}
} else {
console.log("No startContainer found for", this.toString());