@@ -32,11 +32,6 @@ export const deprecateButtonGradientColor = {
32
32
return getAttribute ( 'backgroundColorType' ) === 'gradient' && getAttribute ( 'backgroundColor2' )
33
33
} ,
34
34
migrate : attrNameTemplate => attributes => {
35
- // Do not migrate if the attributes are not eligible.
36
- if ( ! deprecateButtonGradientColor . isEligible ( attrNameTemplate ) ( attributes ) ) {
37
- return attributes
38
- }
39
-
40
35
const getAttrName = getAttrNameFunction ( attrNameTemplate )
41
36
const getAttribute = _attrName => attributes [ getAttrName ( _attrName ) ]
42
37
@@ -59,13 +54,21 @@ export const deprecateButtonGradientColor = {
59
54
const color2ParentHover = getAttribute ( 'backgroundColor2ParentHover' ) || color1ParentHover
60
55
const gradientDirectionParentHover = getAttribute ( 'backgroundGradientDirectionParentHover' ) || getAttribute ( 'backgroundGradientDirectionParentHover' ) === 0 ? getAttribute ( 'backgroundGradientDirectionParentHover' ) : 90
61
56
62
- if ( color1 && color2 ) {
57
+ const isColor1Gradient = color1 && color1 . includes ( 'linear-gradient' )
58
+ const isColor2Gradient = color2 && color2 . includes ( 'linear-gradient' )
59
+ if ( color1 && color2 && ! isColor1Gradient && ! isColor2Gradient ) {
63
60
newAttributes [ getAttrName ( 'backgroundColor' ) ] = `linear-gradient(${ gradientDirection } deg, ${ color1 } 0%, ${ color2 } 100%)`
64
61
}
65
- if ( color1Hover && color2Hover ) {
62
+
63
+ const isColor1HoverGradient = color1Hover && color1Hover . includes ( 'linear-gradient' )
64
+ const isColor2HoverGradient = color2Hover && color2Hover . includes ( 'linear-gradient' )
65
+ if ( color1Hover && color2Hover && ! isColor1HoverGradient && ! isColor2HoverGradient ) {
66
66
newAttributes [ getAttrName ( 'backgroundColorHover' ) ] = `linear-gradient(${ gradientDirectionHover } deg, ${ color1Hover } 0%, ${ color2Hover } 100%)`
67
67
}
68
- if ( color1ParentHover && color2ParentHover ) {
68
+
69
+ const isColor1ParentHoverGradient = color1ParentHover && color1ParentHover . includes ( 'linear-gradient' )
70
+ const isColor2ParentHoverGradient = color2ParentHover && color2ParentHover . includes ( 'linear-gradient' )
71
+ if ( color1ParentHover && color2ParentHover && ! isColor1ParentHoverGradient && ! isColor2ParentHoverGradient ) {
69
72
newAttributes [ getAttrName ( 'backgroundColorParentHover' ) ] = `linear-gradient(${ gradientDirectionParentHover } deg, ${ color1ParentHover } 0%, ${ color2ParentHover } 100%)`
70
73
}
71
74
}
0 commit comments