Skip to content

Commit

Permalink
Make passed focusTrapOptions immutable
Browse files Browse the repository at this point in the history
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 emberjs/ember.js#19548. The change here treats that object as immutable.
  • Loading branch information
simonihmig committed May 26, 2021
1 parent 4bcb685 commit c2760e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addon/modifiers/focus-trap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c2760e5

Please sign in to comment.