Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#11 closed bug (fixed)

$.css(imgelem, 'height') return NaN if image has no size

Reported by: stefan.petre@… Owned by:
Priority: major Milestone: 1.0
Component: core Version: 1.0
Keywords: Cc:
Blocked by: Blocking:

Description

$.css(imgelem, 'height') return NaN if image has no size

Change History (4)

comment:1 Changed 13 years ago by Gilles

Milestone: 1.0
Priority: majorblocker

This code below fixes it, but i don't know if it is the correct way of fixing it.


$.getCSS = function(e,p) {

Adapted from Prototype 1.4.0

if ( p == 'height'
p == 'width' ) {

Handle extra width/height provided by the W3C box model var ph = !$.boxModel ? 0 :

parseInt($.css(e,"paddingTop")) + parseInt($.css(e,"paddingBottom")) +

parseInt($.css(e,"borderTop")) + parseInt($.css(e,"borderBottom"))
0;

var pw = !$.boxModel ? 0 :

parseInt($.css(e,"paddingLeft")) + parseInt($.css(e,"paddingRight")) +

parseInt($.css(e,"borderLeft")) + parseInt($.css(e,"borderRight"))
0;

var oHeight, oWidth;

if ($.css(e,"display") != 'none') {

oHeight = e.offsetHeight oWidth = e.offsetWidth
parseInt(e.style.height,10) 0;
parseInt(e.style.width,10) 0;

} else {

var els = e.style; var ov = els.visibility; var op = els.position; var od = els.display; els.visibility = 'hidden'; els.position = 'absolute'; els.display = ;

oHeight = e.clientHeight oWidth = e.clientWidth
parseInt(e.style.height,10);
parseInt(e.style.width,10);

els.display = od; els.position = op; els.visibility = ov;

}

return p == 'height' ?

(oHeight - ph < 0 ? 0 : oHeight - ph) : (oWidth - pw < 0 ? 0 : oWidth - pw);

}

if (e.style[p]) {

return e.style[p];

} else if (e.currentStyle) {

return e.currentStyle[p];

} else if (document.defaultView && document.defaultView.getComputedStyle) {

p = p.replace(/([A-Z])/g,"-$1"); p = p.toLowerCase(); var s = document.defaultView.getComputedStyle(e,""); var r = s ? s.getPropertyValue(p) : p; return r;

} else {

return null;

}

};


comment:2 Changed 13 years ago by Gilles

Bah, hate this formatting ;)

i committed it to svn

comment:3 Changed 13 years ago by john

Resolution: fixed
Status: newclosed

Fixed in revision [86] by gilles, I touched it up in [87] with some parens.

comment:4 Changed 13 years ago by john

Milestone: 1.0
Priority: blockermajor
Version: 1.0
Note: See TracTickets for help on using tickets.