diff --git a/packages/morph/src/dom.js b/packages/morph/src/dom.js index 1e74fe721..0511dcc81 100644 --- a/packages/morph/src/dom.js +++ b/packages/morph/src/dom.js @@ -57,7 +57,9 @@ export function dom(el) { } export function createElement(html) { - return document.createRange().createContextualFragment(html).firstElementChild + const template = document.createElement('template') + template.innerHTML = html + return template.content.firstElementChild } export function textOrComment(el) { diff --git a/tests/cypress/integration/plugins/morph.spec.js b/tests/cypress/integration/plugins/morph.spec.js index 0ad99544f..45dcc31a6 100644 --- a/tests/cypress/integration/plugins/morph.spec.js +++ b/tests/cypress/integration/plugins/morph.spec.js @@ -342,3 +342,16 @@ test('can morph multiple nodes', get('p:nth-of-type(2)').should(haveText('2')) }, ) + +test('can morph table tr', + [html` + + +
1
+ `], + ({ get }, reload, window, document) => { + let tr = document.querySelector('tr') + window.Alpine.morph(tr, '2') + get('td').should(haveText('2')) + }, +)