@@ -51,6 +51,8 @@ const triggers = {
5151 * @callback saveTrigger
5252 * @param {Object } optionValue the value of the changed option
5353 * @param {string } option the name of the option that has been changed
54+ * @param {Event } event the event (input or change) that triggered saving
55+ * (may not always be defined, e.g. when loading)
5456 * @return {Promise } optionally, to use await
5557 */
5658
@@ -110,10 +112,16 @@ const triggers = {
110112 * @function
111113 * @param {string } [option]
112114 * @param {Object } [optionValue] will be automatically retrieved, if not given
115+ * @param {Event } [event] the event (input or change) that triggered saving
113116 * @returns {Promise }
114117 * @see {@link saveTrigger }
115118 */
116- export async function runSaveTrigger ( option , optionValue ) {
119+ export async function runSaveTrigger ( option , optionValue , event = { } ) {
120+ // create object in case event is empty
121+ if ( ! event ) {
122+ event = { } ;
123+ }
124+
117125 if ( option === undefined ) {
118126 console . info ( "run all save triggers" ) ;
119127
@@ -122,7 +130,7 @@ export async function runSaveTrigger(option, optionValue) {
122130 const option = trigger . option ;
123131 const optionValue = await OptionsModel . getOption ( option ) ;
124132
125- promises . push ( trigger . triggerFunc ( optionValue , option ) ) ;
133+ promises . push ( trigger . triggerFunc ( optionValue , option , event ) ) ;
126134 }
127135 return Promise . all ( promises ) ;
128136 }
@@ -164,7 +172,7 @@ export async function runOverrideSave(option, optionValue, saveTriggerValues) {
164172 return Promise . resolve ( NO_TRIGGERS_EXECUTED ) ;
165173 }
166174
167- console . info ( "runOverrideSave:" , `${ allRegisteredOverrides . length } x` , option , optionValue ) ;
175+ console . info ( "runOverrideSave:" , `${ allRegisteredOverrides . length } x` , option , optionValue , saveTriggerValues , event ) ;
168176
169177 let lastPromise = Promise . resolve ( {
170178 option,
0 commit comments