Skip to content

Commit

Permalink
Fix for #1339, regression that setOpacity IE regression in 1.7.1 when…
Browse files Browse the repository at this point in the history
… setting opacity on an element before it was added to DOM. Also fixed some related tests.
  • Loading branch information
Jorgen Rydenius committed Sep 27, 2012
1 parent addd725 commit aa39832
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/prototype/dom/dom.js
Expand Up @@ -2912,7 +2912,7 @@
}

function hasLayout_IE(element) {
if (!element.currentStyle.hasLayout)
if (!element.currentStyle || !element.currentStyle.hasLayout)
element.style.zoom = 1;
return element;
}
Expand Down
12 changes: 7 additions & 5 deletions test/unit/dom_test.js
Expand Up @@ -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
Expand All @@ -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'));
}
},

Expand Down

0 comments on commit aa39832

Please sign in to comment.