Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const render = (props, ref) => {
const { as: component = tag, class: className, ...rest } = props;
let filteredProps;
// Check if it's an HTML tag and not a custom element
if (typeof component === 'string' && component.indexOf('-') === -1) {
filteredProps = {};
// eslint-disable-next-line guard-for-in
for (const key in rest) {
if (key === 'as' || validAttr(key)) {
// Don't pass through invalid attributes to HTML elements
filteredProps[key] = rest[key];
}
}
} else {
filteredProps = rest;
}
filteredProps.ref = ref;
filteredProps.className = cx(
filteredProps.className || className,
options.class
);
const { vars } = options;
isPropValid = (key: string) => {
// Handle events explicitly as Emotion validates them all as true
if (key.startsWith("on")) {
return !isValidMotionProp(key)
} else {
return emotionIsPropValid(key)
}
}
} catch {
module.exports = memoize(prop => isPropValid(prop) && !regex.test(prop))