forked from mootools/mootools-core
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mootools#2274 from arian/fix-2266-style-opacity
Fix mootools#2266 - Calling setOpacity with null does not remove the style
- Loading branch information
Showing
3 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
--- | ||
name: Element Specs | ||
description: n/a | ||
requires: [Core/Element.Style] | ||
provides: [Element.Style.Specs] | ||
... | ||
*/ | ||
describe('Element.Style', function(){ | ||
|
||
describe('opacity', function(){ | ||
|
||
beforeEach(function(){ | ||
var className = String.uniqueID(); | ||
var style = this.style = document.createElement('style'); | ||
style.type = 'text/css'; | ||
var definition = [ | ||
'.' + className + '{', | ||
'opacity: 0.5;', | ||
'filter: alpha(opacity=50);', | ||
'color: #ff0000;', | ||
'}' | ||
].join(''); | ||
|
||
// fix this, see https://github.com/mootools/mootools-core/issues/2265 | ||
if (style.styleSheet) style.styleSheet.cssText = definition; | ||
else style.set('text', definition); | ||
|
||
document.head.appendChild(style); | ||
|
||
this.element = new Element('div', { | ||
'class': className, | ||
text: 'yo' | ||
}).inject(document.body); | ||
}); | ||
|
||
afterEach(function(){ | ||
this.style.destroy(); | ||
this.element.destroy(); | ||
}); | ||
|
||
it('should get the opacity defined by the CSS', function(){ | ||
expect(this.element.getStyle('opacity')).toEqual(0.5); | ||
}); | ||
|
||
it('should set/overwrite the opacity', function(){ | ||
this.element.setStyle('opacity', 1); | ||
expect(this.element.getStyle('opacity')).toEqual(1); | ||
this.element.setStyle('opacity', null); | ||
expect(this.element.getStyle('opacity')).toEqual(0.5); | ||
}); | ||
|
||
it('should remove the style by setting it to `null`', function(){ | ||
this.element.setStyle('color', '#FF9900'); | ||
expect(this.element.getStyle('color')).toEqual('#ff9900'); | ||
this.element.setStyle('color', null); | ||
expect(this.element.getStyle('color')).toEqual('#ff0000'); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters