Skip to content

Commit

Permalink
Remove duplication of the dimRatio migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Glen Davies committed Oct 10, 2021
1 parent 7cf7656 commit f72d83a
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions packages/block-library/src/cover/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ function dimRatioToClassV1( ratio ) {
: 'has-background-dim-' + 10 * Math.round( ratio / 10 );
}

function migrateDimRatio( attributes ) {
return {
...attributes,
dimRatio: ! attributes.url ? 100 : attributes.dimRatio,
};
}

const blockAttributes = {
url: {
type: 'string',
Expand Down Expand Up @@ -235,12 +242,7 @@ const v7 = {
</div>
);
},
migrate( attributes ) {
return {
...attributes,
dimRatio: ! attributes.url ? 100 : attributes.dimRatio,
};
},
migrate: migrateDimRatio,
};

const v6 = {
Expand Down Expand Up @@ -374,12 +376,7 @@ const v6 = {
</div>
);
},
migrate( attributes ) {
return {
...attributes,
dimRatio: ! attributes.url ? 100 : attributes.dimRatio,
};
},
migrate: migrateDimRatio,
};

const v5 = {
Expand Down Expand Up @@ -476,12 +473,7 @@ const v5 = {
</div>
);
},
migrate( attributes ) {
return {
...attributes,
dimRatio: ! attributes.url ? 100 : attributes.dimRatio,
};
},
migrate: migrateDimRatio,
};

const v4 = {
Expand Down Expand Up @@ -578,12 +570,7 @@ const v4 = {
</div>
);
},
migrate( attributes ) {
return {
...attributes,
dimRatio: ! attributes.url ? 100 : attributes.dimRatio,
};
},
migrate: migrateDimRatio,
};

const v3 = {
Expand Down

0 comments on commit f72d83a

Please sign in to comment.