From c2760e5bf4fee666d72f3a47fa2bdc0af66009c7 Mon Sep 17 00:00:00 2001 From: simonihmig Date: Wed, 26 May 2021 20:18:31 +0200 Subject: [PATCH] Make passed `focusTrapOptions` immutable Recent CI runs of ember-bootstrap for Ember canary and beta started to fail because of deprecations, raised by mutating the `{{hash}}` object inside of this modifier when it is used to pass `focusTrapOptions` as in https://github.com/josemarluedke/ember-focus-trap#with-focus-trap-options. This deprecation was recently added to Ember in https://github.com/emberjs/ember.js/pull/19548. The change here treats that object as immutable. --- addon/modifiers/focus-trap.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/modifiers/focus-trap.js b/addon/modifiers/focus-trap.js index 9a2650a..3ee0c1d 100644 --- a/addon/modifiers/focus-trap.js +++ b/addon/modifiers/focus-trap.js @@ -29,7 +29,8 @@ export default setModifierManager( }, } ) { - state.focusTrapOptions = focusTrapOptions || {}; + // treat the original focusTrapOptions as immutable, so do a shallow copy here + state.focusTrapOptions = { ...focusTrapOptions } || {}; if (typeof isActive !== 'undefined') { state.isActive = isActive; }