polymech-astro/packages/imagetools/api/utils/getAttributesString.js
2025-08-15 20:42:02 +02:00

28 lines
509 B
JavaScript

// @ts-check
import printWarning from "../../utils/printWarning.js";
export default function getAttributesString({
attributes,
element = "",
excludeArray = [],
}) {
const attributesString = Object.keys(attributes)
.filter((key) => {
if (excludeArray.includes(key)) {
printWarning({
key,
element,
});
return false;
}
return true;
})
.map((key) => `${key}="${attributes[key]}"`)
.join(" ");
return attributesString;
}