Skip to content

Commit

Permalink
fix(Forms): Fix use of unpolyfilled structuredClone in useData hook (#…
Browse files Browse the repository at this point in the history
…4108)

We had a spot that was using `window.structuredClone` instead of the
polyfill from `@ungap/structured-clone` that is used everywhere else.

Fixed that spot, and added a rule to eslint to make sure we don't forget
in the future.

Note that I don't make any judgement on whether we should be using this
or not here, just enforcing consistency.

With this linting rule in place:

![CleanShot 2024-10-10 at 14 30
28](https://github.com/user-attachments/assets/a1956341-5d2e-45c8-a59d-cc1db935668f)

---------

Co-authored-by: Kim Røen <[email protected]>
  • Loading branch information
kimroen and Kim Røen authored Oct 11, 2024
1 parent d451793 commit 1f59f10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/dnb-eufemia/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@
}
]
}
],
"no-restricted-globals": [
"error",
{
"name": "structuredClone",
"message": "Import `structuredClone` from '@ungap/structured-clone' instead."
}
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import DataContext, {
} from '../../DataContext/Context'
import { SharedAttachments } from '../../DataContext/Provider'

/**
* Deprecated, as it is supported by all major browsers and Node.js >=v18
* So its a question of time, when we will remove this polyfill
*/
import structuredClone from '@ungap/structured-clone'

type PathImpl<T, P extends string> = P extends `${infer Key}/${infer Rest}`
? Key extends keyof T
? Rest extends ''
Expand Down

0 comments on commit 1f59f10

Please sign in to comment.