Shuichi
Shuichi

Reputation: 11

Uncaught (in promise) Error: item doesn't belong to list paged.polyfill.js error

I'm using PagedJS to add footers and headers to the html templates that we convert to PDF in our website. The code's been working fine for a week until this morning when this error keeps popping up.

Console Error

This is my code:

<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
        <script>
            class MyHandler extends Paged.Handler {
                constructor(chunker, polisher, caller) {
                    super(chunker, polisher, caller);
                }
                beforeParsed(content) {
                    // Chapters Counter
                    $("head").append(`
                        <style>body{counter-set: chapters ${content.querySelectorAll(".chapter").length};}</style>
                    `);                        
                }

                afterPageLayout(pageFragment, page){
                    //if pageFragment does not have a page class, delete it
                    if(pageFragment.querySelectorAll(".page").length == 0){
                        console.log("Hiding page!");
                        console.log(pageFragment);
                        pageFragment.setAttribute("style", "display:none;");
                    }
                }

            }
            Paged.registerHandlers(MyHandler);
        </script>

Any help would be greatly appreciated.

Upvotes: 1

Views: 812

Answers (1)

D4lister
D4lister

Reputation: 1

The problem on my side was this css rule in the direct html wrapper

break-after: page;

after removing it the error was gone

Upvotes: 0

Related Questions