|
413 | 413 | CustomElements.takeRecords();
|
414 | 414 | assert.deepEqual(['a', 'b', 'c', 'd', 'e'], log);
|
415 | 415 | });
|
| 416 | + |
| 417 | + test('instanceof', function() { |
| 418 | + var p = Object.create(HTMLElement.prototype); |
| 419 | + var PCtor = document.registerElement('x-instance', {prototype: p}); |
| 420 | + var x = document.createElement('x-instance'); |
| 421 | + assert.isTrue(CustomElements.instanceof(x, PCtor), 'instanceof failed for x-instance'); |
| 422 | + |
| 423 | + var p2 = Object.create(PCtor.prototype); |
| 424 | + var P2Ctor = document.registerElement('x-instance2', {prototype: p2}); |
| 425 | + var x2 = document.createElement('x-instance2'); |
| 426 | + assert.isTrue(CustomElements.instanceof(x2, P2Ctor), 'instanceof failed for x-instance2'); |
| 427 | + assert.isTrue(CustomElements.instanceof(x2, PCtor), 'instanceof failed for x-instance2'); |
| 428 | + }); |
| 429 | + |
| 430 | + |
| 431 | + test('instanceof typeExtension', function() { |
| 432 | + var p = Object.create(HTMLButtonElement.prototype); |
| 433 | + var PCtor = document.registerElement('x-button-instance', {prototype: p, extends: 'button'}); |
| 434 | + var x = document.createElement('button', 'x-button-instance'); |
| 435 | + assert.isTrue(CustomElements.instanceof(x, PCtor), 'instanceof failed for x-button-instance'); |
| 436 | + assert.isTrue(CustomElements.instanceof(x, HTMLButtonElement), 'instanceof failed for x-button-instance'); |
| 437 | + |
| 438 | + var p2 = Object.create(PCtor.prototype); |
| 439 | + var P2Ctor = document.registerElement('x-button-instance2', {prototype: p2, extends: 'button'}); |
| 440 | + var x2 = document.createElement('button','x-button-instance2'); |
| 441 | + assert.isTrue(CustomElements.instanceof(x2, P2Ctor), 'instanceof failed for x-button-instance2'); |
| 442 | + assert.isTrue(CustomElements.instanceof(x2, PCtor), 'instanceof failed for x-button-instance2'); |
| 443 | + assert.isTrue(CustomElements.instanceof(x2, HTMLButtonElement), 'instanceof failed for x-button-instance2'); |
| 444 | + }); |
| 445 | + |
416 | 446 | });
|
417 | 447 |
|
418 | 448 | htmlSuite('customElements (html)', function() {
|
|
0 commit comments