Skip to content

Commit

Permalink
Fix book index object field (constructor) conflicts bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Folyd committed Oct 30, 2022
1 parent e5fddd9 commit a68119e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion extension/search/book.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class BookSearch {
constructor(bookIndex) {
this.pages = {};
// Create a empyt object with null prototype.
// This can prevent some weired bug, such as the key called `constructor`,
// this would conflict with the prototype constructor method!
this.pages = Object.create(null);
bookIndex.forEach(({ name, url, pages }) => {
pages.forEach(([title, path, parentTitles]) => {
let cleanedTitle = cleanChapterTitle(title);
Expand Down

0 comments on commit a68119e

Please sign in to comment.