mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 11:09:13 +00:00
Fix target logic
This commit is contained in:
4
src/components.d.ts
vendored
4
src/components.d.ts
vendored
@@ -1303,7 +1303,7 @@ export namespace Components {
|
||||
}
|
||||
interface SlTooltip {
|
||||
/**
|
||||
* The tooltip's content.
|
||||
* The tooltip's content. Alternatively, you can use the content slot.
|
||||
*/
|
||||
"content": string;
|
||||
/**
|
||||
@@ -3001,7 +3001,7 @@ declare namespace LocalJSX {
|
||||
}
|
||||
interface SlTooltip {
|
||||
/**
|
||||
* The tooltip's content.
|
||||
* The tooltip's content. Alternatively, you can use the content slot.
|
||||
*/
|
||||
"content"?: string;
|
||||
/**
|
||||
|
||||
@@ -28,7 +28,7 @@ export class Tooltip {
|
||||
|
||||
@Element() host: HTMLSlTooltipElement;
|
||||
|
||||
/** The tooltip's content. */
|
||||
/** The tooltip's content. Alternatively, you can use the content slot. */
|
||||
@Prop() content = '';
|
||||
|
||||
/**
|
||||
@@ -162,7 +162,11 @@ export class Tooltip {
|
||||
}
|
||||
|
||||
getTarget() {
|
||||
const target = this.host.querySelector('*:not(style)') as HTMLElement;
|
||||
// Get the first child that isn't a <style> or content slot
|
||||
const target = [...this.host.children].find(
|
||||
el => el.tagName.toLowerCase() !== 'style' && el.getAttribute('slot') !== 'content'
|
||||
) as HTMLElement;
|
||||
|
||||
if (!target) {
|
||||
throw new Error('Invalid tooltip target: no child element was found.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user