@massimo-cassandro/minimo 1.14.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -62,12 +62,13 @@ import { classnames } from './classnames.js';
|
|
|
62
62
|
* @param {string[]} [args.formats=['avif','webp','pjpg']] - Image formats: the last one is used for the `img` fallback element, the others for the `source` elements.
|
|
63
63
|
* @param {boolean} [args.devMode=false] - When true, `avif` is excluded from `formats` (not supported by the local dev environment).
|
|
64
64
|
* @param {boolean} [args.lazy=true] - When true, the `img` element gets `loading="lazy"`.
|
|
65
|
+
* @param {boolean} [args.condition=true] - When false, the function returns `null` without building anything.
|
|
65
66
|
* @param {string|null} [args.pictureExtraClass=null] - Extra class(es) for the `picture` element.
|
|
66
67
|
* @param {Object<string, *>} [args.pictureExtraAttrs={}] - Extra attributes for the `picture` element.
|
|
67
68
|
* @param {string|null} [args.imgExtraClass=null] - Extra class(es) for the `img` element.
|
|
68
69
|
* @param {Object<string, *>} [args.imgExtraAttrs={}] - Extra attributes for the `img` element.
|
|
69
70
|
* @param {string} [args.alt=''] - `alt` text for the `img` element.
|
|
70
|
-
* @returns {DomBuilderItem|null} The `picture` domBuilder item, or `null` when `baseSrc` is missing.
|
|
71
|
+
* @returns {DomBuilderItem|null} The `picture` domBuilder item, or `null` when `baseSrc` is missing or `condition` is false.
|
|
71
72
|
*/
|
|
72
73
|
export function buildPictureTag({
|
|
73
74
|
baseSrc,
|
|
@@ -79,6 +80,7 @@ export function buildPictureTag({
|
|
|
79
80
|
formats = ['avif', 'webp', 'pjpg'],
|
|
80
81
|
devMode = false,
|
|
81
82
|
lazy = true,
|
|
83
|
+
condition = true,
|
|
82
84
|
pictureExtraClass = null,
|
|
83
85
|
pictureExtraAttrs = {},
|
|
84
86
|
imgExtraClass = null,
|
|
@@ -89,7 +91,7 @@ export function buildPictureTag({
|
|
|
89
91
|
|
|
90
92
|
}){
|
|
91
93
|
|
|
92
|
-
if(baseSrc == null) {
|
|
94
|
+
if(baseSrc == null || !condition) {
|
|
93
95
|
return null;
|
|
94
96
|
}
|
|
95
97
|
|