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

[BUGFIX beta] Async functions being treated as falsey in template conditionals #18651

Merged
merged 1 commit into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ const IfUnlessWithTestCases = [
ObjectProxy.create({ content: true }),
Object,
function() {},
async function() {},
new String('hello'),
new String(''),
new Boolean(true),
Expand Down
1 change: 1 addition & 0 deletions packages/@ember/-internals/runtime/lib/type-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const TYPE_MAP = {
'[object Number]': 'number',
'[object String]': 'string',
'[object Function]': 'function',
'[object AsyncFunction]': 'function',
'[object Array]': 'array',
'[object Date]': 'date',
'[object RegExp]': 'regexp',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ moduleFor(
let length = { length: 12 };
let strangeLength = { length: 'yes' };
let fn = function() {};
let asyncFn = async function() {};
let arrayProxy = ArrayProxy.create({ content: emberA() });

assert.equal(isArray(numarray), true, '[1,2,3]');
Expand All @@ -29,6 +30,7 @@ moduleFor(
assert.equal(isArray(strangeLength), false, '{ length: "yes" }');
assert.equal(isArray(global), false, 'global');
assert.equal(isArray(fn), false, 'function() {}');
assert.equal(isArray(asyncFn), false, 'async function() {}');
assert.equal(isArray(arrayProxy), true, '[]');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ moduleFor(
let a = null;
let arr = [1, 2, 3];
let obj = {};
let instance = EmberObject.create({ method() {} });
let instance = EmberObject.create({
method() {},
async asyncMethod() {},
});

assert.equal(typeOf(), 'undefined', 'undefined');
assert.equal(typeOf(null), 'null', 'null');
Expand All @@ -36,6 +39,7 @@ moduleFor(
assert.equal(typeOf(obj), 'object', 'item of type object');
assert.equal(typeOf(instance), 'instance', 'item of type instance');
assert.equal(typeOf(instance.method), 'function', 'item of type function');
assert.equal(typeOf(instance.asyncMethod), 'function', 'item of type async function');
assert.equal(typeOf(EmberObject.extend()), 'class', 'item of type class');
assert.equal(typeOf(new Error()), 'error', 'item of type error');
}
Expand Down