Skip to content

Commit

Permalink
update api
Browse files Browse the repository at this point in the history
  • Loading branch information
amk221 committed Mar 1, 2023
1 parent f53fc2b commit e8512df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
32 changes: 14 additions & 18 deletions addon/components/expander/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,27 +147,23 @@ class ExpanderComponent extends Component {
});
}

get _api() {
return {
Button: this.Button,
Content: this.renderContent ? this.Content : null,
contentElement: this.contentElement,
toggle: this.toggle,
expand: this.expand,
collapse: this.collapse,
isExpanded: this.isExpanded,
isTransitioning: this.isTransitioning
};
}

api = new Proxy(this, {
get(target, key) {
if (
![
'Button',
'Content',
'contentElement',
'toggle',
'expand',
'collapse',
'isExpanded',
'isTransitioning'
].includes(key) ||
(key === 'Content' && !target.renderContent)
) {
return;
}

return target[key];
return target._api[key];
},

set() {}
});
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/components/expander-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ module('expander', function (hooks) {
</Expander>
`);

assert.strictEqual(this.api.Content, undefined);
assert.strictEqual(this.api.Content, null);
assert.strictEqual(typeof this.api.Button, 'object');
assert.deepEqual(this.api.contentElement, null);
assert.strictEqual(typeof this.api.toggle, 'function');
Expand Down

0 comments on commit e8512df

Please sign in to comment.