()
| 59 | } |
| 60 | |
| 61 | render() { |
| 62 | const { |
| 63 | className, |
| 64 | color, |
| 65 | cssModule, |
| 66 | caret, |
| 67 | split, |
| 68 | nav, |
| 69 | tag, |
| 70 | innerRef, |
| 71 | ...props |
| 72 | } = this.props; |
| 73 | const ariaLabel = props['aria-label'] || 'Toggle Dropdown'; |
| 74 | const classes = mapToCssModules( |
| 75 | classNames(className, { |
| 76 | 'dropdown-toggle': caret || split, |
| 77 | 'dropdown-toggle-split': split, |
| 78 | 'nav-link': nav, |
| 79 | }), |
| 80 | cssModule, |
| 81 | ); |
| 82 | const children = |
| 83 | typeof props.children !== 'undefined' ? ( |
| 84 | props.children |
| 85 | ) : ( |
| 86 | <span className="visually-hidden">{ariaLabel}</span> |
| 87 | ); |
| 88 | |
| 89 | let Tag; |
| 90 | |
| 91 | if (nav && !tag) { |
| 92 | Tag = 'a'; |
| 93 | props.href = '#'; |
| 94 | } else if (!tag) { |
| 95 | Tag = Button; |
| 96 | props.color = color; |
| 97 | props.cssModule = cssModule; |
| 98 | } else { |
| 99 | Tag = tag; |
| 100 | } |
| 101 | |
| 102 | // extracted the rendering of the Tag component |
| 103 | const returnFunction = ({ ref }) => { |
| 104 | const handleRef = (tagRef) => { |
| 105 | ref(tagRef); |
| 106 | const { onToggleRef } = this.context; |
| 107 | if (onToggleRef) onToggleRef(tagRef); |
| 108 | }; |
| 109 | |
| 110 | return ( |
| 111 | <Tag |
| 112 | {...props} |
| 113 | {...{ [typeof Tag === 'string' ? 'ref' : 'innerRef']: handleRef }} |
| 114 | className={classes} |
| 115 | onClick={this.onClick} |
| 116 | aria-expanded={this.context.isOpen} |
| 117 | aria-haspopup={this.getRole()} |
| 118 | children={children} |
nothing calls this directly
no test coverage detected