Skip to content

Commit

Permalink
[BUGFIX beta] Reusing element causes problems in Safari
Browse files Browse the repository at this point in the history
When testing allowed input types, in some versions of Safari the type
cannot be change to `file` if previously set to a different one.

Fixes #14727
  • Loading branch information
anon4562 authored and Serabe committed Jul 24, 2017
1 parent 8e7443f commit 388fac5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 1 addition & 4 deletions packages/ember-glimmer/lib/components/text_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Component from '../component';
import layout from '../templates/empty';
import { TextSupport } from 'ember-views';

let inputTypeTestElement;
const inputTypes = Object.create(null);
function canSetTypeOfInput(type) {
if (type in inputTypes) {
Expand All @@ -23,9 +22,7 @@ function canSetTypeOfInput(type) {
return type;
}

if (!inputTypeTestElement) {
inputTypeTestElement = document.createElement('input');
}
let inputTypeTestElement = document.createElement('input');

try {
inputTypeTestElement.type = type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ moduleFor('Helpers test: {{input}}', class extends InputRenderingTest {
keyCode: 65
});
}

['@test GH#14727 can render a file input after having had render an input of other type']() {
this.render(`{{input type="text"}}{{input type="file"}}`);

this.assert.equal(this.$input()[0].type, 'text');
this.assert.equal(this.$input()[1].type, 'file');
}
});

moduleFor('Helpers test: {{input}} with dynamic type', class extends InputRenderingTest {
Expand Down

0 comments on commit 388fac5

Please sign in to comment.