-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(color-contrast, utils): add more options to color-contrast, add …
…utils.deepMerge, deprecate commons.color.hasValidContrastRatio (#2256) * feat(color-contrast): add options for bold size, font size, and contrast ratio requirements * better option names, properly deep merge options * fix tests * Update lib/checks/color/color-contrast.json Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * Update lib/checks/color/color-contrast-evaluate.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * Update lib/checks/color/color-contrast-evaluate.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * Update lib/checks/color/color-contrast.json Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * Update lib/checks/color/color-contrast-evaluate.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * Update lib/checks/color/color-contrast.json Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * fixes Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
- Loading branch information
1 parent
67d2dca
commit 49fdb46
Showing
9 changed files
with
302 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Deeply merge two objects into a new object without changing any of the source objects. | ||
* @see https://medium.com/javascript-in-plain-english/how-to-merge-objects-in-javascript-98f2209710e3 | ||
* @param {...Object} sources | ||
* @return {Object} | ||
*/ | ||
function deepMerge(...sources) { | ||
const target = {}; | ||
|
||
sources.forEach(source => { | ||
if (!source || typeof source !== 'object' || Array.isArray(source)) { | ||
return; | ||
} | ||
|
||
for (const key of Object.keys(source)) { | ||
if ( | ||
!target.hasOwnProperty(key) || | ||
typeof source[key] !== 'object' || | ||
Array.isArray(target[key]) | ||
) { | ||
target[key] = source[key]; | ||
} else { | ||
target[key] = deepMerge(target[key], source[key]); | ||
} | ||
} | ||
}); | ||
|
||
return target; | ||
} | ||
|
||
export default deepMerge; |
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
Oops, something went wrong.