Fixing a problem with auto-bind and multiple subclasses#348
Merged
Conversation
rorticus
commented
May 20, 2019
| } | ||
|
|
||
| const IGNORE_LIST: (string | symbol)[] = ['constructor', 'render']; | ||
| const IGNORE_LIST: (string | symbol)[] = ['render', ...Object.getOwnPropertyNames(Object.getPrototypeOf({}))]; |
Contributor
Author
There was a problem hiding this comment.
We can exclude all the properties that come from Object.prototype. Technically we might not even need this since we break our loop on subclasses of WidgetBase?
rorticus
commented
May 20, 2019
| p = Object.getPrototypeOf(p); | ||
| } | ||
|
|
||
| keys = keys.filter((k) => typeof instance[k] === 'function' && IGNORE_LIST.indexOf(k) === -1); |
Contributor
Author
There was a problem hiding this comment.
The filtering of keys through the ignore list is now done up here rather than down yonder.
agubler
reviewed
May 21, 2019
| if (autoBindCache.has(prototype)) { | ||
| keys = autoBindCache.get(prototype) as string[]; | ||
| } else { | ||
| let p = prototype; |
Member
There was a problem hiding this comment.
Don't need to do this, just use prototype?
Contributor
Author
There was a problem hiding this comment.
Removed extra variable p!
Member
|
@rorticus It also looks like CI is failing |
agubler
approved these changes
May 29, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: bug
The following has been addressed in the PR:
prettieras per the readme code style guidelinesDescription:
There is a problem with the new auto-bind code when there are multiple levels of inheritance. It currently only applies the binding logic to the first level of inheritance.
To fix this, we're walking the prototype chain up to
WidgetBaseand gathering all the properties from there. Since this is a bit of an expensive operation, we're also caching the result of the property gathering so it only needs to happen once per widget class.