May I suggest that you add the following "|| this.dom.width". If the element is not attached to the document and you:

Code:
elem.setWidth(100)
alert(elem.getWidth());
It will display 0 even though "width" is 100. So, in my code, if offsetWidth is 0 then it will return the value of "width".

Code:
getWidth : function(contentWidth){
        var w = this.dom.offsetWidth || this.dom.width;		
        return contentWidth !== true ? w : w-this.getBorderWidth('lr')-this.getPadding('lr');
},
Thanks!