Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent modifiers with functions from being lost on parse #163

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions addon/components/attach-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,23 @@ export default Component.extend({
}),

_modifiers: computed('arrow', 'flip', 'modifiers', function() {
// Deep copy the modifiers since we might write to the provided hash
// Copy the modifiers since we might write to the provided hash
const modifiers
= this.get('modifiers') ? JSON.parse(JSON.stringify(this.get('modifiers'))) : {};
= this.get('modifiers') ? Object.assign({}, this.get('modifiers')) : {};

const arrow = this.get('arrow');
if (typeof(arrow) === 'boolean') {
if (!modifiers.arrow) {
modifiers.arrow = { enabled: arrow };
} else if (typeof(modifiers.arrow.enbabled) !== 'boolean') {
modifiers.arrow.enabled = arrow;
}
if (typeof(arrow) === 'boolean' && !modifiers.arrow) {
modifiers.arrow = { enabled: arrow };
}

const flipString = this.get('flip');
if (flipString) {
const flipModifier = { behavior: flipString.split(' ') };
if (!modifiers.flip) {
modifiers.flip = { behavior: flipString.split(' ') };
modifiers.flip = flipModifier;
} else if (!modifiers.flip.behavior) {
modifiers.flip.behavior = flipString.split(' ');
// Copy the flip modifier since we are altering the provided hash
modifiers.flip = Object.assign({}, modifiers.flip, flipModifier);
}
}

Expand Down