Skip to content

Commit

Permalink
fix: target-counter leads to pagination to wrong named page
Browse files Browse the repository at this point in the history
- fix #1272
  • Loading branch information
MurakamiShinyu committed Feb 15, 2024
1 parent a461262 commit 980632d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/core/src/vivliostyle/epub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1600,10 +1600,19 @@ export class OPFView implements Vgen.CustomRendererFactory {
loopFrame.continueLoop();
return;
}
// Save the page type and restore it after re-rendering page.
// This is necessary for named page with target-counter() to work.
// (fix for issue #1272)
const { currentPageType, previousPageType } =
viewItem.instance.styler.cascade;
this.counterStore.pushPageCounters(refs.pageCounters);
this.counterStore.pushReferencesToSolve(refs.refs);
const pos = viewItem.layoutPositions[refs.pageIndex];
this.renderSinglePage(viewItem, pos).then((result) => {
viewItem.instance.styler.cascade.currentPageType =
currentPageType;
viewItem.instance.styler.cascade.previousPageType =
previousPageType;
this.counterStore.popPageCounters();
this.counterStore.popReferencesToSolve();
const resultPosition = result.pageAndPosition.position;
Expand Down

0 comments on commit 980632d

Please sign in to comment.