Skip to content

Commit 1c101d5

Browse files
fix: The moveBefore method detection in node environements
1 parent 9c6ac66 commit 1c101d5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dom.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { dashToCamelCase } from './strings.js'
22

33
// Rely on the new moveBefore method to move nodes if it's available https://developer.mozilla.org/en-US/docs/Web/API/Element/moveBefore
4-
const MOVE_BEFORE_METHOD = Element?.prototype?.moveBefore
5-
? 'moveBefore'
6-
: 'insertBefore'
4+
const MOVE_BEFORE_METHOD =
5+
typeof Element !== 'undefined' && Element.prototype.moveBefore
6+
? 'moveBefore'
7+
: 'insertBefore'
78

89
/**
910
* Get all the element attributes as object

0 commit comments

Comments
 (0)