Fix an issue with Element.getDimensions with some element types on non IE-browsers. Closes #7683. [Andrew Dupont]
This commit is contained in:
parent
db2ee67799
commit
930c8f2665
@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Fix an issue with Element.getDimensions with some element types on non IE-browsers. Closes #7683. [Andrew Dupont]
|
||||
|
||||
* Fix Form.disable to work again on non-form elements. Closes #6887. [Mislav Marohnić]
|
||||
|
||||
* Fix an issue with String.prototype.endsWith. Closes #7822. [altblue]
|
||||
|
33
src/dom.js
33
src/dom.js
@ -346,23 +346,28 @@ Element.Methods = {
|
||||
element = $(element);
|
||||
var display = $(element).getStyle('display');
|
||||
if (display != 'none' && display != null) // Safari bug
|
||||
return {width: element.offsetWidth, height: element.offsetHeight};
|
||||
|
||||
return { width: element.offsetWidth, height: element.offsetHeight };
|
||||
|
||||
// All *Width and *Height properties give 0 on elements with display none,
|
||||
// so enable the element temporarily
|
||||
var els = element.style;
|
||||
var originalVisibility = els.visibility;
|
||||
var originalPosition = els.position;
|
||||
var originalDisplay = els.display;
|
||||
els.visibility = 'hidden';
|
||||
els.position = 'absolute';
|
||||
els.display = 'block';
|
||||
var originalWidth = element.clientWidth;
|
||||
var els = element.style, original = {};
|
||||
|
||||
$w('display position visibility height width').each( function(name) {
|
||||
original[name] = els[name];
|
||||
});
|
||||
|
||||
els.visibility = 'hidden';
|
||||
els.display = 'block';
|
||||
|
||||
Position.absolutize(element);
|
||||
var originalWidth = element.clientWidth;
|
||||
var originalHeight = element.clientHeight;
|
||||
els.display = originalDisplay;
|
||||
els.position = originalPosition;
|
||||
els.visibility = originalVisibility;
|
||||
return {width: originalWidth, height: originalHeight};
|
||||
Position.relativize(element);
|
||||
|
||||
$w('display position visibility height width').each( function(name) {
|
||||
els[name] = original[name] || '';
|
||||
});
|
||||
return { width: originalWidth, height: originalHeight };
|
||||
},
|
||||
|
||||
makePositioned: function(element) {
|
||||
|
@ -253,6 +253,11 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="dimensions-nester" style="width: 500px;">
|
||||
<div id="dimensions-nestee" style="display: none">This is a nested DIV. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p id="test-empty"></p>
|
||||
<p id="test-empty-but-contains-whitespace">
|
||||
|
||||
@ -826,6 +831,8 @@
|
||||
assertIdentical(200, $('dimensions-visible-pos-abs').getDimensions().width);
|
||||
assertIdentical(100, $('dimensions-display-none-pos-abs').getDimensions().height);
|
||||
assertIdentical(200, $('dimensions-display-none-pos-abs').getDimensions().width);
|
||||
|
||||
assert($('dimensions-nestee').getDimensions().width <= 500, 'check for proper dimensions of hidden child elements');
|
||||
|
||||
$('dimensions-td').hide();
|
||||
assertIdentical(100, $('dimensions-td').getDimensions().height);
|
||||
|
Loading…
Reference in New Issue
Block a user