Skip to content

Commit

Permalink
fix: make getDisplayName to be almost equal to react getElementName
Browse files Browse the repository at this point in the history
  • Loading branch information
vovkasm committed Jun 24, 2017
1 parent d462a37 commit 6449d80
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/stylable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ import hoistStatics from 'hoist-non-react-statics'
import Node from './node'

function getDisplayName (comp) {
return comp.displayName || comp.name || 'Component'
if (typeof comp.getName === 'function') {
return comp.getName()
}
if (typeof comp.tag === 'number') {
if (typeof comp.type === 'string') {
return comp.type
}
if (typeof comp.type === 'function') {
return comp.displayName || comp.name
}
}
return 'Component'
}

export default function stylable (name) {
Expand Down

0 comments on commit 6449d80

Please sign in to comment.