Side navigation
#5400 closed bug (invalid)
Opened October 21, 2009 02:43PM UTC
Closed October 27, 2010 10:14PM UTC
attr(name), property of an object with dash/hyphen in name returns undefined
Reported by: | kivanov | Owned by: | john |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | selector | Version: | 1.3.2 |
Keywords: | attr dash hyphen | Cc: | |
Blocked by: | Blocking: |
Description
When using attr(name) to get value of parameter for given object, if the name contains any dash/hyphen followed by letter [a-z] it fails on the conversion to upper case by removing the dash/hyphen.
The code that does that is in the attr function:
name = name.replace(/-([a-z])/ig, function(all, letter){ return letter.toUpperCase(); });
Attachments (0)
Change History (5)
Changed October 22, 2009 12:52AM UTC by comment:1
Changed October 22, 2009 01:11PM UTC by comment:2
var _object = new Object(); var _property = "my-property"; _object[_property] = "test"; console.log(_object[_property]); console.log($(_object).attr(_property)); console.log(_object[_property] == $(_object).attr(_property));
Both ways should return the same results, but they are not.
If the property name does not contain "-" followed by [a-z] it works fine.
Changed October 27, 2009 03:17PM UTC by comment:3
Any progress on this bug?
The fix seams easy, just remove the regular expression replacement within the attr function, shown above. Unless that is necessary for some internal use.
Changed April 17, 2010 02:42AM UTC by comment:4
This is still an issue in v1.4.2
Changed October 27, 2010 10:14PM UTC by comment:5
milestone: | 1.3.2 |
---|---|
priority: | major → low |
resolution: | → invalid |
status: | new → closed |
.attr() is designed for use with element attributes and properties, http://api.jquery.com/attr/
Can you provide an example?