Skip to content

Commit 388fac5

Browse files
anon4562Serabe
authored andcommitted
[BUGFIX beta] Reusing element causes problems in Safari
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
1 parent 8e7443f commit 388fac5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/ember-glimmer/lib/components/text_field.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import Component from '../component';
88
import layout from '../templates/empty';
99
import { TextSupport } from 'ember-views';
1010

11-
let inputTypeTestElement;
1211
const inputTypes = Object.create(null);
1312
function canSetTypeOfInput(type) {
1413
if (type in inputTypes) {
@@ -23,9 +22,7 @@ function canSetTypeOfInput(type) {
2322
return type;
2423
}
2524

26-
if (!inputTypeTestElement) {
27-
inputTypeTestElement = document.createElement('input');
28-
}
25+
let inputTypeTestElement = document.createElement('input');
2926

3027
try {
3128
inputTypeTestElement.type = type;

packages/ember-glimmer/tests/integration/helpers/input-test.js

+7
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,13 @@ moduleFor('Helpers test: {{input}}', class extends InputRenderingTest {
425425
keyCode: 65
426426
});
427427
}
428+
429+
['@test GH#14727 can render a file input after having had render an input of other type']() {
430+
this.render(`{{input type="text"}}{{input type="file"}}`);
431+
432+
this.assert.equal(this.$input()[0].type, 'text');
433+
this.assert.equal(this.$input()[1].type, 'file');
434+
}
428435
});
429436

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

0 commit comments

Comments
 (0)