Skip to content

Commit

Permalink
Merge pull request #27 from ExodusMovement/egor/fix/prototype-pollution
Browse files Browse the repository at this point in the history
fix: prototype pollution
  • Loading branch information
headfire94 authored Nov 19, 2024
2 parents 1faed1e + c042b4a commit 6071ff4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,30 @@ export type StyledComponent<P extends object, S extends object> = React.ForwardR
const styled =
<P extends object, S extends object = object, A extends Partial<P> = {}>( // eslint-disable-line @typescript-eslint/no-empty-object-type
Comp: React.ComponentType<P>,
config: Config<P, A> = {}
config: Config<P, A> = Object.create(null)
) =>
<SP extends object>(
componentStyle?: ComponentStyle<P, SP, S>
): StyledComponent<WithOptional<P & SP, keyof A>, S> => {
const {
name,
props: factoryProps = {},
style: factoryStyle = {},
fixedStyle = {},
props: factoryProps = Object.create(null),
style: factoryStyle = Object.create(null),
fixedStyle = Object.create(null),
...opts
} = config

const Styled = React.forwardRef<any, P & StyledProps<S> & { children?: React.ReactNode }>(
(props, ref) => {
const { childRef, children, ...restProps } = props
const { comp, child, childProps = {} } = opts
const { comp, child, childProps = Object.create(null) } = opts

const attrs = opts.attrs
const attrsResult = attrs
? typeof attrs === 'function'
? attrs(restProps as P)
: attrs
: {}
: Object.create(null)

let style = {
...factoryStyle,
Expand Down

0 comments on commit 6071ff4

Please sign in to comment.