ealush / vest

Vest ✅ Declarative validations framework

Home Page:https://vestjs.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot redefine property: name

havlasme opened this issue · comments

Hello,

when I use vest for validation on older browser I get following error:

Uncaught  TypeError: Cannot redefine property: name

I was able to track it down to this script:

https://github.com/ealush/vest/blob/289f26773a1bfc8be8fc383517a9b3f0babd4c07/packages/__shared/src/setFnName.js

The issue is with older browsers which define name property as non-configurable, a workaround could be to check whether is the property configurable before trying to set it.

The reason we need to support for older browsers (Chrome 38 in particular), is that we are developing an application for webos 3.0 which is based on Chrome 38, and the LG does not provide update to newer version.

Thank you @havlasme for bringing this up and digging the source for the issue. This makes perfect sense to me.

setName was created as a way to handle specific internal use cases when used with severe bundle-size optimizations.

We only rely on the function name in one place - specifically, when we use modifiers within shape validation. If you do not use these (which you probably don't), then you will probably not face any issue with this fix.

I released your fix, and it should be available in Version 3.2.4. Please let me know if you need anything else.

Thanks again!

Looks good. Thank you for accepting my merge request.