Skip to main content

Bug Tracker

Side navigation

#11 closed bug (fixed)

Opened June 16, 2006 12:05PM UTC

Closed June 18, 2006 01:34AM UTC

Last modified June 21, 2007 04:15AM UTC

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

Reported by: stefan.petre@gmail.c 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

Attachments (0)
Change History (4)

Changed June 17, 2006 09:08AM UTC by Gilles comment:1

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 || parseInt(e.style.height,10) || 0;

oWidth = e.offsetWidth || 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 || parseInt(e.style.height,10);

oWidth = e.clientWidth || 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;

}

};


Changed June 17, 2006 09:09AM UTC by Gilles comment:2

Bah, hate this formatting ;)

i committed it to svn

Changed June 18, 2006 01:34AM UTC by john comment:3

resolution: → fixed
status: newclosed

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

Changed July 04, 2006 09:47PM UTC by john comment:4

milestone: → 1.0
priority: blockermajor
version: → 1.0