Skip to content

Commit 81bd7a4

Browse files
committed
Removing extra string compare
Removing extra promise then comparison Fixing search test
1 parent b2677a6 commit 81bd7a4

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

addon/mixins/base.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ Semantic.BaseMixin = Ember.Mixin.create({
134134

135135
areAttrValuesEqual(attrName, attrValue, moduleValue) {
136136
return attrValue === moduleValue ||
137-
this._stringCompare(attrValue) === moduleValue ||
138-
attrValue === this._stringCompare(moduleValue) ||
139-
this._stringCompare(attrValue) === this._stringCompare(moduleValue) ||
137+
this._stringCompareIfPossible(attrValue) === this._stringCompareIfPossible(moduleValue) ||
140138
Ember.isEqual(attrValue, moduleValue);
141139
},
142140

@@ -146,6 +144,7 @@ Semantic.BaseMixin = Ember.Mixin.create({
146144
if (module) {
147145
return module.apply(this.getSemanticScope(), arguments);
148146
}
147+
Ember.Logger.warn("The execute method was called, but the Semantic-UI module didn't exist.");
149148
},
150149

151150
actions: {
@@ -230,17 +229,20 @@ Semantic.BaseMixin = Ember.Mixin.create({
230229
};
231230
},
232231

233-
_stringCompare(value) {
232+
_stringCompareIfPossible(value) {
233+
// If its undefined or null, compare on null
234234
if (value == null) {
235235
return null;
236236
}
237+
// We should only compare string values on primitive types
237238
switch (typeof value) {
238239
case "string":
239240
return value;
240241
case "boolean":
241242
case "number":
242243
return value.toString();
243244
default:
245+
// Don't convert to string, otherwise it would be "[Object]"
244246
return value;
245247
}
246248
},

addon/utils/promise-tools.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import Ember from 'ember';
22

33
const isPromise = function(maybePromise) {
4-
if (Ember.PromiseProxyMixin.detect(maybePromise)) {
5-
return true;
6-
}
7-
8-
if (maybePromise instanceof Ember.RSVP.Promise) {
9-
return true;
10-
}
11-
12-
if (maybePromise != null && typeof maybePromise.then === 'function') {
4+
if (maybePromise != null && typeof maybePromise.then === 'function') {
135
return true;
146
}
157
return false;

tests/integration/components/ui-search-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test('it renders', function(assert) {
99
assert.expect(1);
1010

1111
this.render(hbs`
12-
{{#ui-search url="/search"}}
12+
{{#ui-search apiSettings=(hash url="/search")}}
1313
<input class="prompt" type="text" placeholder="Common passwords...">
1414
<div class="results"></div>
1515
{{/ui-search}}

0 commit comments

Comments
 (0)