Browse files

Fix for #1339, regression that setOpacity IE regression in 1.7.1 when…

… setting opacity on an element before it was added to DOM. Also fixed some related tests.
  • Loading branch information...
1 parent addd725 commit aa3983250f4f96d18acbc28938a78d5d01654d4c Jorgen Rydenius committed Sep 27, 2012
Showing with 8 additions and 6 deletions.
  1. +1 −1 src/prototype/dom/dom.js
  2. +7 −5 test/unit/dom_test.js
View
2 src/prototype/dom/dom.js
@@ -2912,7 +2912,7 @@
}
function hasLayout_IE(element) {
- if (!element.currentStyle.hasLayout)
+ if (!element.currentStyle || !element.currentStyle.hasLayout)
element.style.zoom = 1;
return element;
}
View
12 test/unit/dom_test.js
@@ -903,7 +903,10 @@ new Test.Unit.Runner({
this.assert(
$('style_test_3').setOpacity(0.9999999).getStyle('opacity') > 0.999
);
-
+
+ // setting opacity before element was added to DOM
+ this.assertEqual(0.5, new Element('div').setOpacity(0.5).getOpacity());
+
/*
IE <= 7 needs a `hasLayout` for opacity ("filter") to function properly
@@ -927,10 +930,9 @@ new Test.Unit.Runner({
if (ZOOM_AFFECT_HAS_LAYOUT) {
this.assert($('style_test_4').setOpacity(0.5).currentStyle.hasLayout);
- this.assert(2, $('style_test_5').setOpacity(0.5).getStyle('zoom'));
- this.assert(0.5, new Element('div').setOpacity(0.5).getOpacity());
- this.assert(2, new Element('div').setOpacity(0.5).setStyle('zoom: 2;').getStyle('zoom'));
- this.assert(2, new Element('div').setStyle('zoom: 2;').setOpacity(0.5).getStyle('zoom'));
+ this.assertEqual(1, $('style_test_5').setOpacity(0.5).getStyle('zoom'));
+ this.assertEqual(2, new Element('div').setOpacity(0.5).setStyle('zoom: 2;').getStyle('zoom'));
+ this.assertEqual(2, new Element('div').setStyle('zoom: 2;').setOpacity(0.5).getStyle('zoom'));
}
},

0 comments on commit aa39832

Please sign in to comment.