Skip to content

Commit c9335cc

Browse files
authored
fix (performance): removal of the checking of attributes.version in deprecation code (#3503)
1 parent 592f3eb commit c9335cc

File tree

5 files changed

+14
-55
lines changed

5 files changed

+14
-55
lines changed

src/block/blockquote/deprecated.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ const deprecated = [
1313
attributes: attributes( '3.15.3' ),
1414
save: withVersion( '3.15.3' )( Save ),
1515
isEligible: attributes => {
16-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
1716
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
18-
return isNotV4 || hasNumberBlockHeight
17+
return hasNumberBlockHeight
1918
},
2019
migrate: attributes => {
2120
let newAttributes = {
@@ -39,9 +38,8 @@ const deprecated = [
3938
isEligible: attributes => {
4039
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
4140
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
42-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
4341

44-
return hasBlockShadow || hasContainerShadow || isNotV4
42+
return hasBlockShadow || hasContainerShadow
4543
},
4644
migrate: attributes => {
4745
let newAttributes = {
@@ -64,9 +62,8 @@ const deprecated = [
6462
isEligible: attributes => {
6563
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
6664
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
67-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
6865

69-
return hasContainerOpacity || hasBlockOpacity || isNotV4
66+
return hasContainerOpacity || hasBlockOpacity
7067
},
7168
migrate: attributes => {
7269
let newAttributes = {
@@ -87,11 +84,6 @@ const deprecated = [
8784
// layout & containers work.
8885
attributes: attributes( '3.7.9' ),
8986
save: withVersion( '3.7.9' )( Save ),
90-
isEligible: attributes => {
91-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
92-
93-
return isNotV4
94-
},
9587
migrate: attributes => {
9688
let newAttributes = {
9789
...attributes,

src/block/countdown/deprecated.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ const deprecated = [
1717
const hasLabelFontSize = deprecateTypographyFontSize.isEligible( 'label%s' )( attributes )
1818
const hasMessageFontSize = deprecateTypographyFontSize.isEligible( 'message%s' )( attributes )
1919
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
20-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
2120

22-
return hasDigitFontSize || hasLabelFontSize || hasMessageFontSize || hasNumberBlockHeight || isNotV4
21+
return hasDigitFontSize || hasLabelFontSize || hasMessageFontSize || hasNumberBlockHeight
2322
},
2423
migrate: attributes => {
2524
let newAttributes = { ...attributes }
@@ -46,9 +45,8 @@ const deprecated = [
4645
isEligible: attributes => {
4746
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
4847
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
49-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
5048

51-
return hasBlockShadow || hasContainerShadow || isNotV4
49+
return hasBlockShadow || hasContainerShadow
5250
},
5351
migrate: attributes => {
5452
let newAttributes = { ...attributes }
@@ -71,12 +69,11 @@ const deprecated = [
7169
isEligible: attributes => {
7270
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
7371
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
74-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
7572
const hasDigitGradient = deprecateTypographyGradientColor.isEligible( 'digit%s' )( attributes )
7673
const hasLabelGradient = deprecateTypographyGradientColor.isEligible( 'label%s' )( attributes )
7774
const hasMessageGradient = deprecateTypographyGradientColor.isEligible( 'message%s' )( attributes )
7875

79-
return hasContainerOpacity || hasBlockOpacity || isNotV4 || hasDigitGradient || hasLabelGradient || hasMessageGradient
76+
return hasContainerOpacity || hasBlockOpacity || hasDigitGradient || hasLabelGradient || hasMessageGradient
8077
},
8178
migrate: attributes => {
8279
let newAttributes = { ...attributes }
@@ -97,11 +94,6 @@ const deprecated = [
9794
// layout & containers work.
9895
attributes: attributes( '3.7.9' ),
9996
save: withVersion( '3.7.9' )( Save ),
100-
isEligible: attributes => {
101-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
102-
103-
return isNotV4
104-
},
10597
migrate: attributes => {
10698
let newAttributes = { ...attributes }
10799

src/block/feature/deprecated.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ const deprecated = [
6868
attributes: attributes( '3.15.3' ),
6969
save: withVersion( '3.15.3' )( Save ),
7070
isEligible: attributes => {
71-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
7271
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
7372
const hasNumberGaps = deprecateColumnAndRowGap.isEligible( '%s' )( attributes )
74-
return isNotV4 || hasNumberBlockHeight || hasNumberGaps
73+
return hasNumberBlockHeight || hasNumberGaps
7574
},
7675
migrate: attributes => {
7776
let newAttributes = {
@@ -111,9 +110,8 @@ const deprecated = [
111110
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
112111
const hasTopSeparatorShadow = deprecateShadowColor.isEligible( 'topSeparator%s' )( attributes )
113112
const hasBottomSeparatorShadow = deprecateShadowColor.isEligible( 'bottomSeparator%s' )( attributes )
114-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
115113

116-
return hasBlockShadow || hasContainerShadow || hasTopSeparatorShadow || hasBottomSeparatorShadow || isNotV4
114+
return hasBlockShadow || hasContainerShadow || hasTopSeparatorShadow || hasBottomSeparatorShadow
117115
},
118116
migrate: attributes => {
119117
let newAttributes = {
@@ -149,9 +147,8 @@ const deprecated = [
149147
isEligible: attributes => {
150148
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
151149
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
152-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
153150

154-
return hasContainerOpacity || hasBlockOpacity || isNotV4
151+
return hasContainerOpacity || hasBlockOpacity
155152
},
156153
migrate: attributes => {
157154
let newAttributes = {
@@ -185,11 +182,6 @@ const deprecated = [
185182
// layout & containers work.
186183
attributes: attributes( '3.7.9' ),
187184
save: withVersion( '3.7.9' )( Save ),
188-
isEligible: attributes => {
189-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
190-
191-
return isNotV4
192-
},
193185
migrate: attributes => {
194186
let newAttributes = {
195187
...attributes,

src/block/icon-box/deprecated.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ const deprecated = [
1313
attributes: attributes( '3.15.3' ),
1414
save: withVersion( '3.15.3' )( Save ),
1515
isEligible: attributes => {
16-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
1716
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
18-
return isNotV4 || hasNumberBlockHeight
17+
return hasNumberBlockHeight
1918
},
2019
migrate: attributes => {
2120
let newAttributes = {
@@ -50,9 +49,8 @@ const deprecated = [
5049
isEligible: attributes => {
5150
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
5251
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
53-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
5452

55-
return hasBlockShadow || hasContainerShadow || isNotV4
53+
return hasBlockShadow || hasContainerShadow
5654
},
5755
migrate: attributes => {
5856
let newAttributes = {
@@ -86,9 +84,8 @@ const deprecated = [
8684
isEligible: attributes => {
8785
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
8886
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
89-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
9087

91-
return hasContainerOpacity || hasBlockOpacity || isNotV4
88+
return hasContainerOpacity || hasBlockOpacity
9289
},
9390
migrate: attributes => {
9491
let newAttributes = {
@@ -120,11 +117,6 @@ const deprecated = [
120117
// layout & containers work.
121118
attributes: attributes( '3.7.9' ),
122119
save: withVersion( '3.7.9' )( Save ),
123-
isEligible: attributes => {
124-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
125-
126-
return isNotV4
127-
},
128120
migrate: attributes => {
129121
let newAttributes = {
130122
...attributes,

src/block/posts/deprecated.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ const deprecated = [
5353
const hasNumberFontSizeMeta = deprecateTypographyFontSize.isEligible( 'meta%s' )( attributes )
5454
const hasNumberFontSizeReadmore = deprecateTypographyFontSize.isEligible( 'readmore%s' )( attributes )
5555
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
56-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
5756

5857
return hasNumberFontSizeTitle || hasNumberFontSizeCategory || hasNumberFontSizeExcerpt ||
59-
hasNumberFontSizeMeta || hasNumberFontSizeReadmore || hasNumberBlockHeight || isNotV4
58+
hasNumberFontSizeMeta || hasNumberFontSizeReadmore || hasNumberBlockHeight
6059
},
6160
migrate: attributes => {
6261
let newAttributes = {
@@ -124,9 +123,8 @@ const deprecated = [
124123
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
125124
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
126125
const hasImageShadow = deprecateShadowColor.isEligible( 'image%s' )( attributes )
127-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
128126

129-
return hasBlockShadow || hasContainerShadow || hasImageShadow || isNotV4
127+
return hasBlockShadow || hasContainerShadow || hasImageShadow
130128
},
131129
migrate: attributes => {
132130
let newAttributes = {
@@ -194,12 +192,10 @@ const deprecated = [
194192
const hasExcerptGradient = deprecateTypographyGradientColor.isEligible( 'excerpt%s' )( attributes )
195193
const hasMetaGradient = deprecateTypographyGradientColor.isEligible( 'meta%s' )( attributes )
196194
const hasReadmoreGradient = deprecateTypographyGradientColor.isEligible( 'readmore%s' )( attributes )
197-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
198195

199196
return hasContainerOpacity ||
200197
hasBlockOpacity ||
201198
hasImageOpacity ||
202-
isNotV4 ||
203199
hasTitleGradient ||
204200
hasCategoryGradient ||
205201
hasExcerptGradient ||
@@ -261,11 +257,6 @@ const deprecated = [
261257
// layout & containers work.
262258
attributes: attributes( '3.7.9' ),
263259
save: withVersion( '3.7.9' )( Save ),
264-
isEligible: attributes => {
265-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
266-
267-
return isNotV4
268-
},
269260
migrate: attributes => {
270261
let newAttributes = {
271262
...attributes,

0 commit comments

Comments
 (0)