Skip to content

Commit

Permalink
Fix IE9
Browse files Browse the repository at this point in the history
  • Loading branch information
chadhietala committed Jun 27, 2017
1 parent a880d3f commit 16cf5b2
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions packages/@glimmer/runtime/test/initial-render-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ import { NodeDOMTreeConstruction } from "@glimmer/node";

const XHTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';

const IE9_SELECT_QUIRK = (() => {
let select = document.createElement('select');
let option1 = document.createElement('option');
let option2 = document.createElement('option');
option1.setAttribute('selected', '');
select.appendChild(option1);
select.appendChild(option2);
document.body.appendChild(select);
let idx = select.selectedIndex;
option1.selected = false;
idx = select.selectedIndex;
let isSelectQuirk = idx === -1;
document.body.removeChild(select);
return isSelectQuirk;
})();

abstract class RenderTest extends BaseRenderTest {
@test "HTML text content"() {
this.render("content");
Expand Down Expand Up @@ -377,7 +393,13 @@ abstract class RenderTest extends BaseRenderTest {
</select>
`);
selectNode = this.element.childNodes[1];
this.assert.equal(selectNode.selectedIndex, 0);

if (IE9_SELECT_QUIRK) {
this.assert.equal(selectNode.selectedIndex, -1);
} else {
this.assert.equal(selectNode.selectedIndex, 0);
}

this.assertStableNodes();

this.rerender({ selected: '' });
Expand All @@ -389,7 +411,13 @@ abstract class RenderTest extends BaseRenderTest {
</select>
`);
selectNode = this.element.childNodes[1];
this.assert.equal(selectNode.selectedIndex, 0);

if (IE9_SELECT_QUIRK) {
this.assert.equal(selectNode.selectedIndex, -1);
} else {
this.assert.equal(selectNode.selectedIndex, 0);
}

this.assertStableNodes();

this.rerender({ selected: true });
Expand Down

0 comments on commit 16cf5b2

Please sign in to comment.