node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
const ReactPropToAttrNameMap = {
className: 'class',
classname: 'class',
htmlFor: 'for',
crossOrigin: 'crossorigin',
viewBox: 'viewBox',
};
export const toNativeAttrName = (propName, propValue) => {
if (ReactPropToAttrNameMap[propName]) return ReactPropToAttrNameMap[propName];
if (typeof propValue == undefined) return undefined;
if (typeof propValue === 'boolean' && !propValue) return undefined;
if (/[A-Z]/.test(propName)) return propName.toLowerCase();
return propName;
};
export const toNativeAttrValue = (propValue, _propName) => {
if (typeof propValue === 'boolean') return '';
if (Array.isArray(propValue)) return propValue.join(' ');
return propValue;
};
export const toNativeProps = (props = {}) => {
return Object.entries(props).reduce(
(transformedProps, [propName, propValue]) => {
const attrName = toNativeAttrName(propName, propValue);
// prop was stripped. Don't add.
if (!attrName) {
return transformedProps;
}
const attrValue = toNativeAttrValue(propValue, propName);
transformedProps[attrName] = attrValue;
return transformedProps;
},
{}
);
};