Skip to content

Commit d17ee6b

Browse files
author
Chris Joel
committed
Add test to document attached/detached bug.
1 parent 14f2ee1 commit d17ee6b

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.1",
44
"description": "A simple element to fixture DOM for tests.",
55
"dependencies": {
6-
"webcomponentsjs": "webcomponents/webcomponentsjs#~0.6.0"
6+
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.6.0"
77
},
88
"devDependencies": {
99
"web-component-tester": "~2.2.6",

test/test-fixture.html

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,24 @@
1515
<script src="../../web-component-tester/browser.js"></script>
1616
<script src="../test-fixture-mocha.js"></script>
1717

18-
<link rel="import" href="../../polymer/polymer.html">
1918
<link rel="import" href="../test-fixture.html">
2019
</head>
2120
<body>
21+
<script>
22+
(function() {
23+
var proto = Object.create(HTMLElement.prototype);
24+
25+
proto.onDetached = function() {};
26+
27+
proto.detachedCallback = function() {
28+
this.onDetached();
29+
};
30+
31+
document.registerElement('x-custom', {
32+
prototype: proto
33+
});
34+
})();
35+
</script>
2236
<test-fixture id="TrivialFixture">
2337
<template>
2438
<div id="Foo"></div>
@@ -41,6 +55,11 @@
4155
<div id="QuxSibling"></div>
4256
</template>
4357
</test-fixture>
58+
<test-fixture id="AttachedFixture">
59+
<template>
60+
<x-custom></x-custom>
61+
</template>
62+
</test-fixture>
4463
<script>
4564
describe('<test-fixture>', function () {
4665
var trivialFixture;
@@ -59,6 +78,34 @@
5978
multiTemplateFixture.restore();
6079
});
6180

81+
describe('an stamped-out fixture', function () {
82+
var attachedFixture;
83+
var element;
84+
85+
beforeEach(function () {
86+
attachedFixture = document.getElementById('AttachedFixture');
87+
element = attachedFixture.create();
88+
});
89+
90+
afterEach(function () {
91+
attachedFixture.restore();
92+
});
93+
94+
// TODO(cdata): Make this test pass somehow. Currently it fails in
95+
// not-Chrome due to an implementation detail of the Web Components
96+
// polyfill.
97+
xit('detaches the fixtured DOM when it is restored', function () {
98+
var detached = false;
99+
100+
element.onDetached = function () {
101+
detached = true;
102+
};
103+
104+
attachedFixture.restore();
105+
expect(detached).to.be.eql(true);
106+
});
107+
});
108+
62109
describe('when create is called', function () {
63110
var el;
64111

0 commit comments

Comments
 (0)