-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(author): fail on create due to functions as enumerable properties…
… overridden in Object.assign (#3600) *alternate solution to #3578, which had to be reverted because [this.content in GdocPost](https://github.com/owid/owid-grapher/blob/3691a52abfa41b34d7853df84df3329d80a9a187/db/model/Gdoc/GdocPost.ts#L34-L36) would be honored by _.defaults as a property not to override, but would result in the `content` property not respecting `OwidGdocContent` at run time.* ### What changed? This PR promotes GdocBase instance-level functions (e.g. `_enrichSubclassContent` as class methods. ### Why make this change? GdocAuthor (but also GdocPost, GdocHomepage and Gdoc DataInsight) are created from a GdocBase instance (only when inserting a new Gdoc) using `Object.assign(gdocAuthor, gdocBase)`. This call lists all enumerable properties on GdocBase, including instance-level functions such as `_enrichSubclassContent`, and overrides the subclass version. This leads to the subclass enrichment not being performed, and in the case of author creation, an error. ## Follow-up Promoting instance-level functions to class methods on `GdocBase` is enough to solve this issue, but we should consider whether to apply the same treatment to the GdocBase subclasses too.
- Loading branch information
Showing
5 changed files
with
62 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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