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

Remove usage of getWithDefault() #155

Merged
merged 1 commit into from
Jul 17, 2020
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
20 changes: 14 additions & 6 deletions addon/components/fa-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ import Component from '@ember/component'
import layout from '../templates/components/fa-icon'
import { icon, parse, toHtml, config } from '@fortawesome/fontawesome-svg-core'
import { htmlSafe } from '@ember/string'
import { computed, getWithDefault } from '@ember/object'
import { computed, get } from '@ember/object'
import { assign } from '@ember/polyfills';
import appConfig from 'ember-get-config';
import { deprecate } from '@ember/debug';

function getWithDefault (object, key, defaultValue) {
let value = get(object, key);
if (value === undefined) {
return defaultValue;
}
return value;
}

function getConfigOption (key, defaultValue) {
return getWithDefault(appConfig, `fontawesome.${key}`, defaultValue);
}
Expand All @@ -25,9 +33,9 @@ function classList () {
'fa-li': this.get('listItem'),
'fa-flip-horizontal': this.get('flip') === 'horizontal' || this.get('flip') === 'both',
'fa-flip-vertical': this.get('flip') === 'vertical' || this.get('flip') === 'both',
[`fa-${this.get('size')}`]: this.getWithDefault('size', null) !== null,
[`fa-rotate-${this.get('rotation')}`]: this.getWithDefault('rotation', null) !== null,
[`fa-pull-${this.get('pull')}`]: this.getWithDefault('pull', null) !== null
[`fa-${this.get('size')}`]: getWithDefault(this, 'size', null) !== null,
[`fa-rotate-${this.get('rotation')}`]: getWithDefault(this, 'rotation', null) !== null,
[`fa-pull-${this.get('pull')}`]: getWithDefault(this, 'pull', null) !== null
}

return Object.keys(classes)
Expand Down Expand Up @@ -139,8 +147,8 @@ const IconComponent = Component.extend({
const transformProp = this.get('transform')
const transform = objectWithKey('transform', (typeof transformProp === 'string') ? parse.transform(transformProp) : transformProp)
const mask = objectWithKey('mask', normalizeIconArgs(null, this.get('mask')))
const symbol = this.getWithDefault('symbol', false)
let title = this.getWithDefault('title', null)
const symbol = getWithDefault(this, 'symbol', false)
let title = getWithDefault(this, 'title', null)
if (title) {
title = `${title}`;
}
Expand Down