Bug Tracker

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:


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 pbcomm

Can you provide an example?

comment:2 Changed 13 years ago by kivanov

var _object = new Object();
var _property = "my-property";

_object[_property] = "test";

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 kivanov

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:4 Changed 13 years ago by kivanov

This is still an issue in v1.4.2

comment:5 Changed 12 years ago by Rick Waldron

Milestone: 1.3.2
Priority: majorlow
Resolution: invalid
Status: newclosed

.attr() is designed for use with element attributes and properties, http://api.jquery.com/attr/

Note: See TracTickets for help on using tickets.