summaryrefslogtreecommitdiffstats
path: root/wp-includes/js/dist/style-engine.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wp-includes/js/dist/style-engine.js46
1 files changed, 12 insertions, 34 deletions
diff --git a/wp-includes/js/dist/style-engine.js b/wp-includes/js/dist/style-engine.js
index 6d2a32b..8f7250d 100644
--- a/wp-includes/js/dist/style-engine.js
+++ b/wp-includes/js/dist/style-engine.js
@@ -826,33 +826,27 @@ const backgroundImage = {
name: 'backgroundImage',
generate: (style, options) => {
const _backgroundImage = style?.background?.backgroundImage;
- const _backgroundSize = style?.background?.backgroundSize;
- const styleRules = [];
- if (!_backgroundImage) {
- return styleRules;
- }
- if (_backgroundImage?.source === 'file' && _backgroundImage?.url) {
- styleRules.push({
+ if (typeof _backgroundImage === 'object' && _backgroundImage?.url) {
+ return [{
selector: options.selector,
key: 'backgroundImage',
// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
value: `url( '${encodeURI(safeDecodeURI(_backgroundImage.url))}' )`
- });
+ }];
}
- // If no background size is set, but an image is, default to cover.
- if (_backgroundSize === undefined) {
- styleRules.push({
- selector: options.selector,
- key: 'backgroundSize',
- value: 'cover'
- });
+ /*
+ * If the background image is a string, it could already contain a url() function,
+ * or have a linear-gradient value.
+ */
+ if (typeof _backgroundImage === 'string') {
+ return generateRule(style, options, ['background', 'backgroundImage'], 'backgroundImage');
}
- return styleRules;
+ return [];
}
};
const backgroundPosition = {
- name: 'backgroundRepeat',
+ name: 'backgroundPosition',
generate: (style, options) => {
return generateRule(style, options, ['background', 'backgroundPosition'], 'backgroundPosition');
}
@@ -866,23 +860,7 @@ const backgroundRepeat = {
const backgroundSize = {
name: 'backgroundSize',
generate: (style, options) => {
- const _backgroundSize = style?.background?.backgroundSize;
- const _backgroundPosition = style?.background?.backgroundPosition;
- const styleRules = [];
- if (_backgroundSize === undefined) {
- return styleRules;
- }
- styleRules.push(...generateRule(style, options, ['background', 'backgroundSize'], 'backgroundSize'));
-
- // If background size is set to contain, but no position is set, default to center.
- if (_backgroundSize === 'contain' && _backgroundPosition === undefined) {
- styleRules.push({
- selector: options.selector,
- key: 'backgroundPosition',
- value: 'center'
- });
- }
- return styleRules;
+ return generateRule(style, options, ['background', 'backgroundSize'], 'backgroundSize');
}
};
/* harmony default export */ const styles_background = ([backgroundImage, backgroundPosition, backgroundRepeat, backgroundSize]);