Skip to main content

Bug Tracker

Side navigation

#9172 closed bug (wontfix)

Opened May 08, 2011 02:22AM UTC

Closed May 10, 2011 04:29AM UTC

Setting the value attribute for the first time in IE6/7 sets the value property

Reported by: timmywil Owned by:
Priority: low Milestone: 1.next
Component: attributes Version: 1.6
Keywords: Cc:
Blocked by: Blocking:
Description

For .attr("value", "something").

This is an edge case, but I'm not sure how to fix it. Normally, we do

.getAttributeNode("value").nodeValue = "something";

This will leave the value property unaffected. However, if the content attribute does not yet exist on the element (i.e. getAttributeNode returns null), the property is set in IE6/7 when the fallback setAttribute("value", "something") is called. This is usually ok since most elements would have their value set along with defaultValue, but it is a problem with textareas where there can be a value already set that should override the defaultValue( I think ).

http://jsfiddle.net/timmywil/AWhvV/

Attachments (0)
Change History (5)

Changed May 08, 2011 02:22AM UTC by timmywil comment:1

component: unfiledattributes
priority: undecidedlow
status: newopen

Changed May 08, 2011 02:24AM UTC by timmywil comment:2

description: For .attr("value", "something"). \ \ This is an edge case, but I'm not sure how to fix it. Normally, we do \ {{{ \ .getAttributeNode("value").nodeValue = "something"; \ }}} \ This will leave the value property unaffected. However, if the content attribute does not yet exist on the element (i.e. getAttributeNode returns null), the property is set in IE6/7. This is usually ok since most elements would have their value set along with defaultValue, but it is a problem with textareas where there can be a value already set that should override the defaultValue( I think ). \ \ http://jsfiddle.net/timmywil/AWhvV/For .attr("value", "something"). \ \ This is an edge case, but I'm not sure how to fix it. Normally, we do \ {{{ \ .getAttributeNode("value").nodeValue = "something"; \ }}} \ This will leave the value property unaffected. However, if the content attribute does not yet exist on the element (i.e. getAttributeNode returns null), the property is set in IE6/7 when the fallback setAttribute("value", "something") is called. This is usually ok since most elements would have their value set along with defaultValue, but it is a problem with textareas where there can be a value already set that should override the defaultValue( I think ). \ \ http://jsfiddle.net/timmywil/AWhvV/

Changed May 09, 2011 09:13AM UTC by RogerW@l-space-design.com comment:3

I think I've got something similar to this in IE9.

var $node = $('<input type="text" value="44" />').appendTo(parentElem);

$node.val(xmlNode.textContent);

where xmlNode is an XML attribute, and textContent = "5000"

I check before the val call, and value is set to 44, after the val call value is set to 5000, but 44 appears in the browser.

Changed May 09, 2011 09:34AM UTC by RogerW@l-space-design.com comment:4

Replying to [comment:3 RogerW@…]:

I think I've got something similar to this in IE9.

Never mind. I had a parentElem.innerHTML += statement later in the code which was triggering the dom fragments to be recreated.

Changed May 10, 2011 04:29AM UTC by timmywil comment:5

resolution: → wontfix
status: openclosed

We're falling back to prop for value for back compat.