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

Commit

Permalink
Add multiple insert test for attachedCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jan 14, 2014
1 parent c962035 commit 2a8c5f6
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/js/customElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
assert.equal(xbooboo.style.fontSize, '32pt');
});


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

test('document.register detachedCallbacks in prototype', function(done) {
test('document.register attachedCallbacks in prototype', function(done) {
var inserted = 0;
var XBooPrototype = Object.create(HTMLElement.prototype);
XBooPrototype.attachedCallback = function() {
inserted++;
};
var XBoo = document.registerElement('x-boo-at', {
prototype: XBooPrototype
});
var xboo = new XBoo();
assert.equal(inserted, 0, 'inserted must be 0');
work.appendChild(xboo);
CustomElements.takeRecords();
assert.equal(inserted, 1, 'inserted must be 1');
work.removeChild(xboo);
CustomElements.takeRecords();
assert(!xboo.parentNode);
work.appendChild(xboo);
CustomElements.takeRecords();
assert.equal(inserted, 2, 'inserted must be 2');
done();
});

test('document.register detachedCallbacks in prototype', function(done) {
var ready, inserted, removed;
var XBooPrototype = Object.create(HTMLElement.prototype);
XBooPrototype.detachedCallback = function() {
Expand Down

0 comments on commit 2a8c5f6

Please sign in to comment.