Skip to content
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

Rewrite the clone and merge helpers #4422

Merged
merged 1 commit into from
Jul 1, 2017

Conversation

simonbrunel
Copy link
Member

The clone method now accepts any type of input but also recursively perform a deep copy of the array items. Rewrite the configMerge and scaleMerge helpers which now rely on a new generic and customizable merge method, that one accepts a target object in which multiple sources are deep copied. Note that the target (first argument) is not cloned and will be modified after calling merge(target, sources). Add a mergeIf helper which merge the source properties only if they do not exist in the target object.

@chartjs/maintainers please review this PR carefully since it impacts the whole config process :)

// Type changed. Bring in the new defaults before we bring in valueObj so that valueObj can override the correct scale defaults
base[key][index] = helpers.configMerge(base[key][index], axisDefaults, valueObj);

helpers.scaleMerge = function(/* objects ... */) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't wait until v3 when this goes away since everything has a key

The `clone` method now accepts any type of input but also recursively perform a deep copy of the array items. Rewrite the `configMerge` and `scaleMerge` helpers which now rely on a new generic and customizable `merge` method, that one accepts a target object in which multiple sources are deep copied. Note that the target (first argument) is not cloned and will be modified after calling `merge(target, sources)`. Add a `mergeIf` helper which merge the source properties only if they do not exist in the target object.
@simonbrunel simonbrunel merged commit 225bfd3 into chartjs:master Jul 1, 2017
@simonbrunel simonbrunel deleted the helpers-merge branch July 1, 2017 12:51
yofreke pushed a commit to yofreke/Chart.js that referenced this pull request Dec 30, 2017
The `clone` method now accepts any type of input but also recursively perform a deep copy of the array items. Rewrite the `configMerge` and `scaleMerge` helpers which now rely on a new generic and customizable `merge` method, that one accepts a target object in which multiple sources are deep copied. Note that the target (first argument) is not cloned and will be modified after calling `merge(target, sources)`. Add a `mergeIf` helper which merge the source properties only if they do not exist in the target object.
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
The `clone` method now accepts any type of input but also recursively perform a deep copy of the array items. Rewrite the `configMerge` and `scaleMerge` helpers which now rely on a new generic and customizable `merge` method, that one accepts a target object in which multiple sources are deep copied. Note that the target (first argument) is not cloned and will be modified after calling `merge(target, sources)`. Add a `mergeIf` helper which merge the source properties only if they do not exist in the target object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants