May I suggest that you add the following "|| this.dom.width". If the element is not attached to the document and you:
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:elem.setWidth(100) alert(elem.getWidth());
Thanks!Code:getWidth : function(contentWidth){ var w = this.dom.offsetWidth || this.dom.width; return contentWidth !== true ? w : w-this.getBorderWidth('lr')-this.getPadding('lr'); },