File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -30,18 +30,23 @@ function parseJStoCSS(document, styles) {
3030
3131function getStyleDeclaration ( document , css ) {
3232 const styles = { } ;
33+
34+ // The next block is necessary to normalize colors
3335 const copy = document . createElement ( 'div' ) ;
34- Object . keys ( css ) . forEach ( property => {
35- copy . style [ property ] = css [ property ] ;
36- styles [ property ] = copy . style [ property ] ;
36+ Object . keys ( css ) . forEach ( prop => {
37+ copy . style [ prop ] = css [ prop ] ;
38+ styles [ prop ] = copy . style [ prop ] ;
3739 } ) ;
40+
3841 return styles ;
3942}
4043
4144function styleIsSubset ( styles , computedStyle ) {
4245 return (
4346 ! ! Object . keys ( styles ) . length &&
44- Object . entries ( styles ) . every ( ( [ prop , value ] ) => computedStyle . getPropertyValue ( prop . toLowerCase ( ) ) === value )
47+ Object . entries ( styles ) . every (
48+ ( [ prop , value ] ) => computedStyle [ prop ] === value || computedStyle . getPropertyValue ( prop . toLowerCase ( ) ) === value
49+ )
4550 ) ;
4651}
4752
@@ -58,7 +63,7 @@ function printoutStyles(styles) {
5863
5964function expectedStyleDiff ( expected , computedStyles ) {
6065 const received = Array . from ( computedStyles )
61- . filter ( prop => expected [ prop ] )
66+ . filter ( prop => expected [ prop ] !== undefined )
6267 . reduce (
6368 ( obj , prop ) =>
6469 Object . assign ( obj , {
You can’t perform that action at this time.
0 commit comments