-
Notifications
You must be signed in to change notification settings - Fork 935
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
fix: IE11 clone() #1029
fix: IE11 clone() #1029
Conversation
Moving `_whitelist` and `_blacklist` initializations inside `proto` fixes: `createSetIterator called on incompatible receiver` error in IE11
Not sure why CI didn't run here, but this likely breaks a lot of things...I don't think this is fixing the issue correctly, but it's hard to understand what the IE error even is here. |
src/mixed.js
Outdated
@@ -92,6 +89,9 @@ const proto = (SchemaType.prototype = { | |||
__isYupSchema__: true, | |||
|
|||
constructor: SchemaType, | |||
|
|||
_whitelist: new RefSet(), | |||
_blacklist: new RefSet(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this moves the properties to the prototype which is incorrect. They are instance properties and should not be shared between all instances of SchemaType, which is what would happen here.
Thanks for providing more context! It looks like this only fixes the issue because it avoids trying to clone the RefSets, but it creates a subtle and bad bug where one instance of these RefSets is shared between all schema globally. Judging from the error it looks like the actual bug is in the Concat method, but not sure where. And to be clear even with es6 classes this would still not work. The code as it's is functionally the same as an es6 class |
Thanks for responding! I ran my local tests badly, which misled me that everything was fine. |
Also, |
Improvement on previous commit
For some reason, the RefSets aren't cloned during the SchemaType.clone and this causes all of the IE11 bugs. This new commit doesn’t break any of the 536 tests, would you accept it? |
Moving
_whitelist
and_blacklist
initializations insideproto
fixes:createSetIterator called on incompatible receiver
error in IE11