Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update flatten.ts #4282

Closed
wants to merge 1 commit into from
Closed

Update flatten.ts #4282

wants to merge 1 commit into from

Conversation

iegik
Copy link

@iegik iegik commented Mar 22, 2024

To avoid situation where provided object do not have prototype we should use Object.hasOwn.

Test1:

objToCssArray(Object.create(null))

Test2:

const obj = Object.create(null);
obj.color = 'red';
objToCssArray(obj)

Test3:

const obj = {
  hasOwnProperty: () => { /*...*/ return true },
}
objToCssArray(obj)

To avoid situation where provided object do not have prototype we should use Object.hasOwn.

Test1:

`objToCssArray(Object.create(null))`

Test2:

```
const obj = Object.create(null);
obj.color = 'red';
objToCssArray(obj)
```

Test3:

```
const obj = {
  hasOwnProperty: () => { /*...*/ return true },
}
objToCssArray(obj)
```
@quantizor
Copy link
Contributor

This change unfortunately regresses hot path performance by a decent amount
Screenshot 2024-04-30 at 5 35 35 PM

@iegik
Copy link
Author

iegik commented May 17, 2024

I think, that in case, when it runs on the server side (NextJS SSR) - will be better to choose more secure option :)

@quantizor quantizor closed this May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants