Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit c962035

Browse files
committed
test for detachedCallback firing without attachCallback
1 parent 51c8369 commit c962035

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

test/js/customElements.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,41 @@
243243
xboo.setAttribute('foo', 'zot');
244244
});
245245

246+
test('document.register detachedCallbacks in prototype', function(done) {
247+
var ready, inserted, removed;
248+
var XBooPrototype = Object.create(HTMLElement.prototype);
249+
XBooPrototype.detachedCallback = function() {
250+
removed = true;
251+
}
252+
var XBoo = document.registerElement('x-boo-ir2', {
253+
prototype: XBooPrototype
254+
});
255+
var xboo = new XBoo();
256+
assert(!removed, 'removed must be false [XBoo]');
257+
work.appendChild(xboo);
258+
CustomElements.takeRecords();
259+
work.removeChild(xboo);
260+
CustomElements.takeRecords();
261+
assert(removed, 'removed must be true [XBoo]');
262+
//
263+
ready = inserted = removed = false;
264+
var XBooBooPrototype = Object.create(XBooPrototype);
265+
XBooBooPrototype.detachedCallback = function() {
266+
XBoo.prototype.detachedCallback.call(this);
267+
};
268+
var XBooBoo = document.registerElement('x-booboo-ir2', {
269+
prototype: XBooBooPrototype
270+
});
271+
var xbooboo = new XBooBoo();
272+
assert(!removed, 'removed must be false [XBooBoo]');
273+
work.appendChild(xbooboo);
274+
CustomElements.takeRecords();
275+
work.removeChild(xbooboo);
276+
CustomElements.takeRecords();
277+
assert(removed, 'removed must be true [XBooBoo]');
278+
done();
279+
});
280+
246281
test('document.register can use Functions as definitions', function() {
247282
// function used as Custom Element defintion
248283
function A$A() {

0 commit comments

Comments
 (0)