From 35f6037f7f06894fd5beca1d1db710d72b0bc74c Mon Sep 17 00:00:00 2001 From: Patrick Custer Date: Thu, 27 Feb 2025 14:31:43 -0500 Subject: [PATCH] include hipsList in options merge --- src/js/Aladin.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/Aladin.js b/src/js/Aladin.js index a775141a..860dc6fd 100644 --- a/src/js/Aladin.js +++ b/src/js/Aladin.js @@ -306,10 +306,16 @@ export let Aladin = (function () { var options = { ...Aladin.DEFAULT_OPTIONS, ...requestedOptions, + // In javascript, arrays like objects are copied by reference. + // To not change the default aladin options afterwards, + // we use the spread operator to create a new object for the gridOptions property gridOptions:{ ...Aladin.DEFAULT_OPTIONS.gridOptions, ...requestedOptions.gridOptions - } + }, + // and use the slice method to create a new array for the hipsList property: + // https://stackoverflow.com/questions/7486085/copy-array-by-value + hipsList: requestedOptions.hipsList || Aladin.DEFAULT_OPTIONS.hipsList.slice() }; this.options = options;