Skip to content

Commit

Permalink
Fix an issue in IE9 beta where the value attribute of an <input> el…
Browse files Browse the repository at this point in the history
…ement would not get set.
  • Loading branch information
savetheclocktower committed Oct 5, 2010
1 parent a4cb9bf commit c05412b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Fix an issue in IE9 beta where the `value` attribute of an <input> element would not get set. (Andrew Dupont)

* Move all offset methods to layout.js, eliminating some code repetition.

* Remove unit test for passing a DOM node into `Object.toJSON`. To continue to support this use case would require bypassing IE's native JSON implementation. (Tobie Langel, Thomas Fuchs, Samuel Lebeau, Andrew Dupont)
Expand Down
12 changes: 10 additions & 2 deletions src/dom/dom.js
Expand Up @@ -172,13 +172,21 @@ if (!Node.ELEMENT_NODE) {
attributes = attributes || { };
tagName = tagName.toLowerCase();
var cache = Element.cache;

if (HAS_EXTENDED_CREATE_ELEMENT_SYNTAX && attributes.name) {
tagName = '<' + tagName + ' name="' + attributes.name + '">';
delete attributes.name;
delete attributes.name;
return Element.writeAttribute(document.createElement(tagName), attributes);
}

if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));
return Element.writeAttribute(cache[tagName].cloneNode(false), attributes);

// Don't use the cache if we're setting the `type` attribute, as on an
// INPUT element. This prevents an issue with IE9 beta.
var node = ('type' in attributes) ? document.createElement(tagName) :
cache[tagName].cloneNode(false);

return Element.writeAttribute(node, attributes);
};

Object.extend(global.Element, element || { });
Expand Down
5 changes: 5 additions & 0 deletions test/unit/fixtures/form.html
Expand Up @@ -117,3 +117,8 @@
<form id="form_with_inputs_needing_encoding" style="display:none">
<input type="hidden" name="user[wristbands][][nickname]" id="fine_1" value="Hässlich" />
</form>

<form id="form_with_troublesome_input_names">
<input type="text" name="length" value="foo" />
<input type="text" name="bar" value="baz" />
</form>
6 changes: 5 additions & 1 deletion test/unit/form_test.js
Expand Up @@ -370,6 +370,7 @@ new Test.Unit.Runner({
},

testSerializeFormTroublesomeNames: function() {
var hash = { length: 'foo', bar: 'baz' };
var el = new Element('form', {
action: '/'
});
Expand All @@ -385,6 +386,9 @@ new Test.Unit.Runner({
});
el.appendChild(input);
el.appendChild(input2);
this.assertHashEqual({ length: 'foo', bar: 'baz' }, el.serialize(true));
this.assertHashEqual(hash, el.serialize(true));

var form = $('form_with_troublesome_input_names');
this.assertHashEqual(hash, form.serialize(true));
}
});

0 comments on commit c05412b

Please sign in to comment.