Skip to content

Commit 41c87e3

Browse files
committed
refactor(readability): prefer document.write
1 parent 21eb765 commit 41c87e3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/metascraper-readability/benchmark/document-write.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
const { Window } = require('happy-dom')
44
const { readFileSync } = require('fs')
5+
const path = require('path')
56

67
const url = 'https://arxiv.org/pdf/2412.06592'
7-
const html = readFileSync('./fixture.html', 'utf8')
8+
const html = readFileSync(path.resolve(__dirname, './fixture.html'), 'utf8')
89

910
const isEqual = (value1, value2) =>
1011
JSON.stringify(value1) === JSON.stringify(value2)
@@ -20,7 +21,7 @@ const cases = {
2021
const window = new Window({ url })
2122
const document = window.document
2223
document.write(html)
23-
await window.happyDOM.waitUntilComplete()
24+
// await window.happyDOM.waitUntilComplete()
2425
return document
2526
}
2627
}

packages/metascraper-readability/src/worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const getDocument = ({ url, html }) => {
1515
const { Window } = require('happy-dom')
1616
const window = new Window({ url })
1717
const document = window.document
18-
document.documentElement.innerHTML = html
18+
document.write(html)
1919
return document
2020
}
2121

0 commit comments

Comments
 (0)