From 388fac59bef8d00c1e7ff207cc1e96901c5d6068 Mon Sep 17 00:00:00 2001 From: anon4562 <5o20od+9em5xhwulvet4@sharklasers.com> Date: Thu, 22 Dec 2016 10:26:41 -0800 Subject: [PATCH] [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 --- packages/ember-glimmer/lib/components/text_field.js | 5 +---- .../ember-glimmer/tests/integration/helpers/input-test.js | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/ember-glimmer/lib/components/text_field.js b/packages/ember-glimmer/lib/components/text_field.js index 84e0306c49d..161fac6455a 100644 --- a/packages/ember-glimmer/lib/components/text_field.js +++ b/packages/ember-glimmer/lib/components/text_field.js @@ -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) { @@ -23,9 +22,7 @@ function canSetTypeOfInput(type) { return type; } - if (!inputTypeTestElement) { - inputTypeTestElement = document.createElement('input'); - } + let inputTypeTestElement = document.createElement('input'); try { inputTypeTestElement.type = type; diff --git a/packages/ember-glimmer/tests/integration/helpers/input-test.js b/packages/ember-glimmer/tests/integration/helpers/input-test.js index 36150bb024a..aed3252c66e 100644 --- a/packages/ember-glimmer/tests/integration/helpers/input-test.js +++ b/packages/ember-glimmer/tests/integration/helpers/input-test.js @@ -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 {