Internet Explorer 8 - Cannot change Type property #2510

Closed
DissidentRage opened this Issue Jun 28, 2013 · 5 comments

Projects

None yet

5 participants

@DissidentRage

The line "node.type = type;" does not work as Internet Explorer does not permit you to change the type property. The element will need to be copied and replaced to get around this.

if (input.value != 't') propertySetters.type = function(node, type){
var value = node.value;
node.type = type;
node.value = value;
};

@fselhorst

This worked for me :

if (input.value != 't') propertySetters.type = function(node, type){
var value = node.value;
node.setAttribute(type, value)
};

@ibolmo ibolmo added IE bug labels Mar 3, 2014
@ibolmo ibolmo modified the milestone: 1.5.1, 1.5 Mar 3, 2014
@ibolmo
Member
ibolmo commented Mar 3, 2014

If you could supply a jsfiddle, it'll help us create a test case to check against.

@ibolmo ibolmo modified the milestone: 1.5.1, 1.5 Mar 3, 2014
@WernerWenz

I've set up a pretty simple test case here:
http://jsfiddle.net/FRLKV/

This blows IE8 at
https://github.com/mootools/mootools-core/blob/14a2aaaee57670fe558b40b306e2489adf57cd39/Source/Element/Element.js#L601

According to http://api.jquery.com/attr/ it's default behavior of IE that
type attributes for Input Elements become read-only, once the element is in the document.
As consequence they disallowed type changes via jQuery on any Browser (see notes).

If required, a workaround would most likeley - as initially stated - boil down to reinsert a modified copy of the immutable input.

@WernerWenz

Actually you've already Documented it yourself in your own Docs, that its's an invalid action on IE8 or lower:
http://mootools.net/docs/core/Element/Element#Element:set

Saying this, I would rather classify this issue as a feature request for the issue rather than a bug.

@SergioCrisostomo
Member

As this is IE8 specific and documented I would say this is a wont-fix and should be closed. The solution often used in IE is to create a new element with the new type and replace the existing one. But that seems a bit ugly. Fortunately IE9+ don't have this problem anymore.

Thank you @DissidentRage for pointing out a valid problem and you others for extra input.
As always do comment again if you feel this should not be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment