Bug Tracker

Modify

Ticket #5400 (closed bug: invalid)

Opened 4 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 4 years ago by pbcomm

Can you provide an example?

comment:2 Changed 4 years ago by kivanov

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 4 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 3 years ago by kivanov

This is still an issue in v1.4.2

comment:5 Changed 3 years ago by rwaldron

  • Priority changed from major to low
  • Status changed from new to closed
  • Resolution set to invalid
  • Milestone 1.3.2 deleted

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.