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

Commit 2a8c5f6

Browse files
committed
Add multiple insert test for attachedCallback
1 parent c962035 commit 2a8c5f6

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

test/js/customElements.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@
173173
assert.equal(xbooboo.style.fontSize, '32pt');
174174
});
175175

176-
177176
test('document.register [created|attached|detached]Callbacks in prototype', function(done) {
178177
var ready, inserted, removed;
179178
var XBooPrototype = Object.create(HTMLElement.prototype);
@@ -243,7 +242,30 @@
243242
xboo.setAttribute('foo', 'zot');
244243
});
245244

246-
test('document.register detachedCallbacks in prototype', function(done) {
245+
test('document.register attachedCallbacks in prototype', function(done) {
246+
var inserted = 0;
247+
var XBooPrototype = Object.create(HTMLElement.prototype);
248+
XBooPrototype.attachedCallback = function() {
249+
inserted++;
250+
};
251+
var XBoo = document.registerElement('x-boo-at', {
252+
prototype: XBooPrototype
253+
});
254+
var xboo = new XBoo();
255+
assert.equal(inserted, 0, 'inserted must be 0');
256+
work.appendChild(xboo);
257+
CustomElements.takeRecords();
258+
assert.equal(inserted, 1, 'inserted must be 1');
259+
work.removeChild(xboo);
260+
CustomElements.takeRecords();
261+
assert(!xboo.parentNode);
262+
work.appendChild(xboo);
263+
CustomElements.takeRecords();
264+
assert.equal(inserted, 2, 'inserted must be 2');
265+
done();
266+
});
267+
268+
test('document.register detachedCallbacks in prototype', function(done) {
247269
var ready, inserted, removed;
248270
var XBooPrototype = Object.create(HTMLElement.prototype);
249271
XBooPrototype.detachedCallback = function() {

0 commit comments

Comments
 (0)