Skip to content

Commit 1a56a09

Browse files
committed
Add failing spec for replace with no parent
1 parent 4c68624 commit 1a56a09

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,30 @@ asyncTest('replaces element on 200 status', 2, function() {
176176
});
177177
});
178178

179+
asyncTest('does not replace element if it has no parent', 2, function() {
180+
var div = document.createElement('div');
181+
div.innerHTML = '<include-fragment src="/hello">loading</include-fragment>';
182+
document.getElementById('qunit-fixture').appendChild(div);
183+
184+
var fragment = div.firstChild;
185+
fragment.remove();
186+
187+
window.addEventListener('unhandledrejection', function() {
188+
ok(false);
189+
});
190+
191+
fragment.addEventListener('load', function() {
192+
equal(document.querySelector('#replaced'), null);
193+
start();
194+
195+
div.appendChild(fragment);
196+
197+
setTimeout(function() {
198+
equal(document.querySelector('#replaced').textContent, 'hello');
199+
}, 10);
200+
});
201+
});
202+
179203
asyncTest('replaces with several new elements on 200 status', 3, function() {
180204
var div = document.createElement('div');
181205
div.innerHTML = '<include-fragment src="/one-two">loading</include-fragment>';

0 commit comments

Comments
 (0)