diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:51:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:51:18 +0000 |
commit | 0e41b5d52fdc6af6442816b5f465c9db9f84e126 (patch) | |
tree | e139a90049b158d4eed892d1662ee7f5c358fa31 /wp-includes/js/dist/style-engine.js | |
parent | Adding upstream version 6.5.5+dfsg1. (diff) | |
download | wordpress-upstream.tar.xz wordpress-upstream.zip |
Adding upstream version 6.6.1+dfsg1.upstream/6.6.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/js/dist/style-engine.js')
-rw-r--r-- | wp-includes/js/dist/style-engine.js | 46 |
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]); |