Skip to content

Commit

Permalink
Fixes for FallbackStyles HOC usage on button.
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Jul 17, 2018
1 parent 813c538 commit 76e55a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core-blocks/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ const { getComputedStyle } = window;

const FallbackStyles = withFallbackStyles( ( node, ownProps ) => {
const { textColor, backgroundColor } = ownProps;
const backgroundColorValue = backgroundColor && backgroundColor.value;
const textColorValue = textColor && textColor.value;
//avoid the use of querySelector if textColor color is known and verify if node is available.
const textNode = ! textColor && node ? node.querySelector( '[contenteditable="true"]' ) : null;
const textNode = ! textColorValue && node ? node.querySelector( '[contenteditable="true"]' ) : null;
return {
fallbackBackgroundColor: backgroundColor || ! node ? undefined : getComputedStyle( node ).backgroundColor,
fallbackTextColor: textColor || ! textNode ? undefined : getComputedStyle( textNode ).color,
fallbackBackgroundColor: backgroundColorValue || ! node ? undefined : getComputedStyle( node ).backgroundColor,
fallbackTextColor: textColorValue || ! textNode ? undefined : getComputedStyle( textNode ).color,
};
} );

Expand Down

0 comments on commit 76e55a1

Please sign in to comment.