Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX release-1-13] Make type attr on inputs immutable for IE8 #12351

Closed
wants to merge 3 commits into from

Conversation

xcskier56
Copy link

This fixes #11553 and #12295 as well as tildeio/htmlbars#380. This works by detecting if the browser can change the type attr on an input after it has been appended to a node, and then if it cannot, unbinding the type attr so that it is set on the input immediately before being appended to a node.

@stavarotti
Copy link

👍 I was able to build and run in IE 8 using the VM's on https://dev.modern.ie/tools/vms/windows/. I was however, not able to run the tests in IE 8 due to various exceptions. @rwjblue is the test suite for 1.13.x supposed to run on IE 8?

@ghost
Copy link

ghost commented Sep 22, 2015

I can confirm that this fixes the IE8 input incompatibility.

@jerel
Copy link
Contributor

jerel commented Sep 25, 2015

Any word on when a bugfix release will happen with this fix in it? I've got some pretty ugly hacks in place trying to workaround all components that use {{input}} and they aren't working too well.

@ef2k
Copy link

ef2k commented Sep 25, 2015

👍 great work! Thanks @xcskier56 for taking the time to fix this, can't wait to see it in the next release.

@ef2k
Copy link

ef2k commented Sep 29, 2015

Bump. Will the next release include this bugfix? Any ETA on it? Thanks in advance.

// IE8 Support: IE8 cannot change the type attr of an input after it has been appended to
// any node. Therefore, we detect if the browser cannot change the type of the input after
// being appended, and unbind type.
if (normalized.type && !canChangeType) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems more complicated than I would have assumed.

I was thinking something like:

if (attrs.type && !canChangeType) {
  attrs.type = getValue(attrs.type); // forces a static value
}

Done around here would do the trick.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simpler version works but you don't get warnings. The warnings are a nice feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simpler is much less likely to cause other issues down the line. We should ensure that a deprecation is printed when you use IE8 (I vaguely think that there is already), and remove the extra complication here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simple version does not address #12295. For the case where the component definition defines the type attribute instead of the template we need to compute the property value.

@xcskier56
Copy link
Author

@rwhblue, thanks for the feedback. I will get to work on this. Is there an estimated date for the next release that this could make it into?

@rwjblue
Copy link
Member

rwjblue commented Sep 30, 2015

I do not have a specific timeline for the next release. This seems to be a big enough fix to justify a releas shortly after landing,

Also, remember that you can use the latests builds from release-1-13 branch at any time (it is available as both bower install --save ember#release-1-13 and from builds.emberjs.com...).

@stavarotti
Copy link

@xcskier56 Any progress on the changes? I can help were needed.

@gauthierm
Copy link

I opened xcskier56#1 to clean up this PR slightly.

@gauthierm
Copy link

Does anyone know if the code in views/text_field.js is obsolete if this PR is merged?

Only compute mutable type flag once and clean up var initilization.
@xcskier56
Copy link
Author

@gauthierm, thanks for the help in finishing up the PR. Looking forward to landing this.

@benkonrath
Copy link

@xcskier56 Thanks for working on this issue. I'm eager to see this merged. Does @gauthierm's change address all of the concerns that @rwjblue had? Let me know if I can help in any way.

@xcambar
Copy link
Contributor

xcambar commented Oct 28, 2015

ping @xcskier56 (wrong autocomplete in #12351 (comment))

@benkonrath
Copy link

Thanks @xcambar - sorry for the noise.

@gauthierm
Copy link

@rwjblue do you have time to look at this PR again?

@jerel
Copy link
Contributor

jerel commented Nov 3, 2015

Is there anything more we as the community can do to help get this merged? #12351 (comment) says to bower install from release-1-13 but if I'm not mistaken this PR has to be merged before it's on that branch :)

@gauthierm
Copy link

@jerel It's not merged so using the latest build won't include the bug fix. You'll have to:

  • fork the ember.js repo
  • apply this PR to the 1.13 branch
  • do a build (remember to update the version before running the build)
  • fork the ember shim repo
  • branch from the release-1-13 branch
  • copy the build into the shim repo
  • commit, tag and push to your own remote

I've done all that at https://github.com/silverorange/ember/tree/1.13.10-so.1. You can fork off that if you want. I do not recommend using it directly in your bower config as it may disappear after this PR is merged.

@jerel
Copy link
Contributor

jerel commented Nov 6, 2015

Has anyone else explicitly tested a radio button with this patch?

Inputs don't cause IE8 to crash now but I'm still seeing a text input like is reported in #12295 with {{input type="radio" name="foo" value=false}}. The markup that gets rendered is:

<input name="foo" class="ember-view ember-text-field" id="ember644" type="radio" value="false"/>`

and it shows up as a text input.

And @gauthierm, thanks so much for sharing that release.

@gauthierm
Copy link

@jerel I have not tried a radio input. I've only used "email" and "text".

@gauthierm
Copy link

@jerel I've tried this PR with radio inputs in IE8 on Windows XP and it works fine.

@gauthierm
Copy link

@jerel okay, I see the behaviour of #12295 when using a component. The built-in {{input}} helper does render a radio button in IE8 but a custom component does not.

@xcskier56
Copy link
Author

@gauthierm, this is the situation where I was hoping the attrs.ie8SafeInput would help. In your custom component, you can add this flag to see how it will behave in IE8. In my app, I've added that to all of the inputs and other components so that I catch issues like this earlier.

You can see it here around line 274

@gauthierm
Copy link

@xcskier56 I think it can be handled as part of this PR. I have a fix for #12295 which I'll submit a PR for in a sec.

@jerel
Copy link
Contributor

jerel commented Nov 9, 2015

@gauthierm I just rechecked here and the built in helper {{input type="radio"}} does not work for me on IE8. {{input type="radio" ie8SafeInput=true}} does work however but components like https://github.com/yapplabs/ember-radio-button won't work because they don't handle the attribute.

@gauthierm
Copy link

@xcskier56 @jerel xcskier56#2 should fix default type attribute values on custom components.


function canChangeTypeAfterRender(attrs) {
// This permits testing of the unbound type attr behavior outside of IE8.
if (attrs.ie8SafeInput) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A [BUGFIX release] should not add new API. I would be fine with either prevent any changing of type after initial render (this was asserted in some versions of Ember prior to 1.13 anyways) or simply ignoring and deferring the testing to applications if they need to confirm things work...

@rwjblue
Copy link
Member

rwjblue commented Nov 10, 2015

I left a couple more comments. If someone can address them (either by updating this PR or pulling these commits into another), we can try to finally get this dealt with.

Sorry for the delays here.

@rwjblue
Copy link
Member

rwjblue commented Nov 12, 2015

Does anyone know if the code in views/text_field.js is obsolete if this PR is merged?

Which code specifically? The entire file is certainly not obsolete (it is what defines the component used by {{input type="text"}} helper)...

@gauthierm
Copy link

Does anyone know if the code in views/text_field.js is obsolete if this PR is merged?

Which code specifically? The entire file is certainly not obsolete (it is what defines the component used by {{input type="text"}} helper)...

https://github.com/emberjs/ember.js/blob/release-1-13/packages/ember-views/lib/views/text_field.js#L13-L35 and associated code. It looks like it's doing some extra checking of whether the type attribute can be bound.

@rwjblue
Copy link
Member

rwjblue commented Nov 12, 2015

Merged in under #12596.

@rwjblue rwjblue closed this Nov 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants