Skip to content

Commit 0205af8

Browse files
committed
guard against document.body === null (which happens in Electron)
1 parent ae7d15f commit 0205af8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ let shaderCache = new WeakMap
2323

2424
// Safari does not support font-stretch
2525
let isStretchSupported = false
26-
let el = document.body.appendChild(document.createElement('div'))
27-
el.style.font = 'italic small-caps bold condensed 16px/2 cursive'
28-
if (getComputedStyle(el).fontStretch) {
29-
isStretchSupported = true
26+
if (document.body) {
27+
let el = document.body.appendChild(document.createElement('div'))
28+
el.style.font = 'italic small-caps bold condensed 16px/2 cursive'
29+
if (getComputedStyle(el).fontStretch) {
30+
isStretchSupported = true
31+
}
32+
document.body.removeChild(el)
3033
}
31-
document.body.removeChild(el)
3234

3335
class GlText {
3436
constructor (o) {

0 commit comments

Comments
 (0)