in partnership with mediatemple

Ticket #798 (new defect)

Opened 3 months ago

Last modified 2 months ago

Form w/ an input name or id of "position" breaks in IE

Reported by: SecretAgentRege Owned by:
Type: defect Priority: minor
Milestone: Mootools version 1.2 Component: Core
Keywords: Cc:

Description

In IE7 & IE6, If you have a form with any type of input that has a name or id value of "position," the form breaks when you try to pass it through mootools.

This fails in IE:

<script type="text/javascript">
	window.addEvent('domready',function(){
	    $('formid');
	});
</script>
<form id="formid" name="formid">
	<input type="text" name="position" id="position" />
</form>

I came across this on an employer's form that asked for the position that the user held within their company and had the select box's name as "position". Took me a while to figure out it was the input's name that was the problem (and not the form itself).

Change History

Changed 2 months ago by kasi

In general it breaks when the name exists in Element.Prototype. So this also fails

    <input name="match"/>
    <input name="search"/>
    <input name="addEvent"/>

This one would work:

$.element = function(el, notrash){
	$uid(el);
	if (!notrash && !el.$family && !(/^object|embed$/i).test(el.tagName)){
		var proto = Element.Prototype;
        if ((/^form$/i).test(el.tagName)){
            for (var p in proto) 
                if (!el.elements[p]) el[p] = proto[p];
        }
        else {
		    for (var p in proto) el[p] = proto[p];
        }
	};
	return el;
};

But that means, when you have an element named addEvent for example, you can not add events to a form any more! I think there is no workaround for this, except having a big warning in the docs.

KASI

Note: See TracTickets for help on using tickets.