#1020 ✓resolved
njakobsen

context bug in toCSS and typo cssNameFor

Reported by njakobsen | April 6th, 2010 @ 12:27 AM | in 1.7

toCSS seems to have a bug that causes the keys.each iterator use the wrong context for 'this'.

toCSS: function() {
      var args = $A(arguments);
      var keys = (args.length === 0) ? Element.Layout.PROPERTIES :
       args.join(' ').split(' ');
      var css = {};
      keys.each( function(key) {
        if (!Element.Layout.PROPERTIES.include(key)) return;
        if (Element.Layout.COMPOSITE_PROPERTIES.include(key)) return;

        var value = this.get(key);
        if (value) css[cssNameFor(key)] = value + 'px';
      });
      return css;
    },

should be

toCSS: function() {
      var args = $A(arguments);
      var keys = (args.length === 0) ? Element.Layout.PROPERTIES :
       args.join(' ').split(' ');
      var css = {};
      keys.each( function(key) {
        if (!Element.Layout.PROPERTIES.include(key)) return;
        if (Element.Layout.COMPOSITE_PROPERTIES.include(key)) return;

        var value = this.get(key);
        if (value) css[cssNameFor(key)] = value + 'px';
      }, this);
      return css;
    },

Also, cssNameFor calls a function 'includes' on a string. It looks like this should actually be 'include'.

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

Referenced by

Pages