Skip to content

Commit aabcd76

Browse files
committed
[bugfix][API] Prevent duplicate members from filters
Duplicate members were being added directly to the public member array on each toggle. This PR ensures that there is a new array created each time the computed is run.
1 parent 335c0c2 commit aabcd76

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

addon/components/docs-demo/component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default Component.extend({
5050
and whether or not it is active.
5151
5252
@computed snippets
53+
@private
5354
@type Array<Object>
5455
@readOnly
5556
*/

addon/utils/computed.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,21 @@ export function memberFilter(classKey, memberType) {
6767
let showPrivate = this.get('showPrivate');
6868
let showDeprecated = this.get('showDeprecated');
6969

70+
let members = [];
71+
7072
if (showInternal === false && memberType !== 'arguments') {
71-
return [];
73+
return members;
7274
}
7375

7476
let capitalKey = capitalize(memberType);
7577

76-
let members = showInherited ? klass.get(`allPublic${capitalKey}`) : klass.get(`public${capitalKey}`);
78+
79+
let publicMembers = showInherited ? klass.get(`allPublic${capitalKey}`) : klass.get(`public${capitalKey}`);
7780
let privateMembers = showInherited ? klass.get(`allPrivate${capitalKey}`) : klass.get(`private${capitalKey}`);
7881
let protectedMembers = showInherited ? klass.get(`allProtected${capitalKey}`) : klass.get(`protected${capitalKey}`);
7982

83+
members.push(...publicMembers);
84+
8085
if (showPrivate) {
8186
members.push(...privateMembers);
8287
}

0 commit comments

Comments
 (0)