mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Moved code to not break test cases.
This commit is contained in:
parent
e323b9d879
commit
3a0f10195b
2 changed files with 11 additions and 11 deletions
|
@ -574,6 +574,17 @@ class Contents {
|
||||||
|
|
||||||
if(this.epubcfi.isCfiString(target)) {
|
if(this.epubcfi.isCfiString(target)) {
|
||||||
let range = new EpubCFI(target).toRange(this.document, ignoreClass);
|
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) {
|
||||||
if (range.startContainer.nodeType === Node.ELEMENT_NODE) {
|
if (range.startContainer.nodeType === Node.ELEMENT_NODE) {
|
||||||
|
|
|
@ -968,17 +968,6 @@ class EpubCFI {
|
||||||
missed = this.fixMiss(startSteps, start.terminal.offset, doc, needsIgnoring ? ignoreClass : null);
|
missed = this.fixMiss(startSteps, start.terminal.offset, doc, needsIgnoring ? ignoreClass : null);
|
||||||
range.setStart(missed.container, missed.offset);
|
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 {
|
} else {
|
||||||
console.log("No startContainer found for", this.toString());
|
console.log("No startContainer found for", this.toString());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue