Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: [FIXED][3.0RC1]bodyStyle not applied padding

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Jul 2007
    Location
    Moscow, Russia
    Posts
    295

    Default [FIXED][3.0RC1]bodyStyle not applied padding

    Hi, with ext 2.2.1 working great, but now padding not applied for any cmp.
    For example:
    Code:
    Ext.Window({
        bodyStyle: 'background: #cad9ec; padding: 7px 7px 0 7px',
    });
    New config attributes or anything else?

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    No, applyStyles no longer trims whitespace (should this be classified as a bug?).

    This should work:
    Code:
    bodyStyle: 'background:#cad9ec;padding:7px 7px 0 7px',

  3. #3
    Sencha User
    Join Date
    Jul 2007
    Location
    Moscow, Russia
    Posts
    295

    Default

    Ohh, thank you!
    IMO, this is bug, because clean code markup with whitespaces is good practice.

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    I'll move this thread to the bugs section...

  5. #5
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    Fixed in SVN, strings will now be trimmed appropriately.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    I'm not sure that the solution is the best. Perhaps some benchmarking could be done?

    Generating a trim function on every trip through applyStyles must be a bit inefficient. Wouldn't using String's Ext-supplied trim call on each element be better?

  7. #7
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

    I've modified the implementation slightly. The problem it was having is trying to match pairs when having trailing spaces. If we trim the initial input then split on :|;, then we can just trim the values and be sure they aren't null.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  8. #8
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    I see that each individual element of the Array must be trimmed. But given that we are using a RegExp to split on, that could be extended to "consume" any whitespace:

    Code:
            applyStyles : function(el, styles){
                if(styles){
                    var i = 0,
                        len;
                        
                    el = Ext.fly(el);                    
                    if(Ext.isFunction(styles)){
                        styles = styles.call();
                    }
                    if (typeof styles == "string") {
                        styles = styles.split(/\s*(?::|;)\s*/g);
                        for (len = styles.length; i < len;) {
                            el.setStyle(styles[i++], styles[i++]);
                        }
                    }else if (Ext.isObject(styles)){
                        el.setStyle(styles);
                    }            
                }    
            },

  9. #9
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Is it important that a style property is set to null for an empty style specification?

    If so, then

    Code:
            applyStyles : function(el, styles){
                if(styles){
                    var i = 0,
                        len;
                        
                    el = Ext.fly(el);                    
                    if(Ext.isFunction(styles)){
                        styles = styles.call();
                    }
                    if (typeof styles == "string") {
                        styles = styles.split(/\s*(?::|;)\s*/g);
                        for (len = styles.length; i < len;) {
                            el.setStyle(styles[i++]||null, styles[i++]||null);
                        }
                    }else if (Ext.isObject(styles)){
                        el.setStyle(styles);
                    }            
                }    
            },

  10. #10
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488

    Default

    It's worthwhile to take a look at any possible optimizations here but we should be trimming out the whitespace for all of these styles.
    Aaron Conran
    @aconran

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •