Opened 13 years ago
Closed 12 years ago
#5400 closed bug (invalid)
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(); });
Change History (5)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
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.
comment:3 Changed 13 years ago by
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.
comment:5 Changed 12 years ago by
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?