( content: string | TooltipOptions, element: Element, )
| 98 | @example addTooltip('Does something', $('.some-existing-button')) |
| 99 | */ |
| 100 | export default function addTooltip( |
| 101 | content: string | TooltipOptions, |
| 102 | element: Element, |
| 103 | ): void { |
| 104 | if (!element.parentElement) { |
| 105 | throw new Error('Element has no parent. Use `tooltipped` instead for elements not yet attached to a parent.'); |
| 106 | } |
| 107 | |
| 108 | const tooltip = createTooltipFor(element, content); |
| 109 | // Attach to element first just in case the global container is missing. This also "activates" the tool-tip element. |
| 110 | element.append(tooltip); |
| 111 | attachToDocument(tooltip); |
| 112 | } |
no test coverage detected