#1247 new

Possible performance optimization in Element.getStyle()

Reported by Nightfly | April 26th, 2011 @ 06:30 PM

Element.getStyle(element) uneccesarily adds Element methods to element (see comment in code below):

  getStyle: function(element, style) {
    // The "Element" methods that are added here are never used.
    element = $(element); 
    // ---

    style = style == 'float' ? 'cssFloat' : style.camelize();
    var value = element.style[style];
    if (!value || value == 'auto') {
      var css = document.defaultView.getComputedStyle(element, null);
      value = css ? css[style] : null;
    if (style == 'opacity') return value ? parseFloat(value) : 1.0;
    return value == 'auto' ? null : value;

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket