-
Notifications
You must be signed in to change notification settings - Fork 2k
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(runtime.js): partials compile not caching #1600
Conversation
Reintroduce assigning env.partials to container.partials if no options.partials is set. Also allow assigning options.partials to container.partials if only that one exists. This solves handlebars-lang#1598
Perhaps |
I think the overhead of the shallow-copy step is negligible. #1594 is also related to that place. It makes sure that the helpers-object has a "null"-prototype, because some exploits have used "defineGetter" to do bad things and the "helpers"-object is accessible from the template. Merging here makes sure that the "helpers"-option is not used "as is" and together with #1594 it ensure the null-prototype ( @ole-martin could you rename the merge-function to something that explains what the function is doing. It's not a simple "merge", but a "merge if needed" or a "first non-null or merge" or something like that. If you find a good name, short yet describing what the function does, please take it. But "firstNonNullOrMerged" would be fine to. I was confused the first time I read that code and my intention (over time) is to make the Handlebars code more explanatory and clean (not by comments, but by good naming). |
@nknapp Updated function name to "mergeIfNeeded" now 👍 |
@ole-martin forgive me for delaying this further again. Although I had added some change requests, I haven't had time for a full review yet. And now it is getting too late again. But I will look... |
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.
I have added some change-requests.
Have you made sure that the test fails without you patch?
I will merge the PR without the sinon
-changes if you don't want to do that. But it would be nicer that way.
Update: I hope you are not that fast with starting the rebase: I have just added another commit to the 4.x
-branch, because "sinon" was not defined as global variable in the eslint-configuration. It now is.
@nknapp I've moved the test to regressions.js and changed it to use sinon-spy & Handlebars.create(). I've also verified that without the changes to runtime the test fails with
|
Great, I'll have another look this evening. But I think its fine now. Thanks. |
Reintroduce assigning env.partials to container.partials if no options.partials is set. Also allow assigning options.partials to container.partials if only that one exists. This solves #1598