Skip to content

Commit

Permalink
Merge pull request #16750 from ampatspell/is-object-guard-for-is-proxy
Browse files Browse the repository at this point in the history
[BUGFIX release] bring back isObject guard for ember-utils/is_proxy
  • Loading branch information
rwjblue authored Jun 15, 2018
2 parents 9ba382d + 6346e82 commit 396424c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/ember-utils/lib/is_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import WeakSet from './weak_set';
const PROXIES = new WeakSet();

export function isProxy(object: any | undefined | null) {
return PROXIES.has(object);
if (isObject(object)) {
return PROXIES.has(object);
}
return false;
}

export function setProxy(object: object) {
Expand Down
18 changes: 18 additions & 0 deletions packages/ember-utils/tests/is_proxy_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { isProxy, setProxy } from '..';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

moduleFor(
'ember-utils isProxy',
class extends AbstractTestCase {
['@test basic'](assert) {
let proxy = {};
setProxy(proxy);

assert.equal(isProxy(proxy), true);

assert.equal(isProxy({}), false);
assert.equal(isProxy(undefined), false);
assert.equal(isProxy(null), false);
}
}
);

0 comments on commit 396424c

Please sign in to comment.