Bug Tracker

Ticket #1249 (closed enhancement: invalid)

Opened 8 years ago

Last modified 7 years ago

Normalizing borderWidth in ideal situations

Reported by: blairmitchelmore Owned by:
Priority: trivial Milestone:
Component: core Version: 1.1.2
Keywords: Cc:
Blocking: Blocked by:


If you define an element with a border of "1px solid black" then the call $(element).css("borderWidth") firefox returns "1px 1px 1px 1px"

It would be neat if jQuery could recognize cases like this and fix it to return a single value.

One possible implementation: curCSS: function(...) {


if (prop == 'borderWidth') {

var vals = ret.split(/\s+/); if (vals.length > 1) {

vals = jQuery.map(vals,function(a,i) {

return jQuery.inArray(a,vals) != i ? null : a;

}); ret = vals.length == 1 ? vals[0] : ret;



return ret;


Change History

comment:1 Changed 7 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

I have needed borderWidth values for two plugins, and both times I've needed to collect the individual border widths for each side of the element.

Since the caller often wouldn't know which case applied before making the call, it would have to handle both the current situation (four values separated by spaces) and the "optimized" case (a single value). So it seems like this would make things more complicated for both jQuery and the caller.

Note: See TracTickets for help on using tickets.