Skip to content

Commit a11e87b

Browse files
committed
Only replace when parentNode exists
1 parent 1a56a09 commit a11e87b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

include-fragment-element.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313

1414
function handleData(el, data) {
1515
return data.then(function(html) {
16-
el.insertAdjacentHTML('afterend', html);
17-
el.parentNode.removeChild(el);
16+
var parentNode = el.parentNode;
17+
if (parentNode) {
18+
el.insertAdjacentHTML('afterend', html);
19+
parentNode.removeChild(el);
20+
}
1821
}, function() {
1922
el.classList.add('is-error');
2023
});

0 commit comments

Comments
 (0)