Skip to content

Commit

Permalink
feat(react-utilities): generalize is HTMLElement attribute to unknown (
Browse files Browse the repository at this point in the history
  • Loading branch information
bsunderhus authored Dec 22, 2022
1 parent d2daecb commit 2d76331
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "feat: generalize is HTMLElement attribute to unknown",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ export function getTriggerChild<TriggerChildProps>(children: TriggerProps<Trigge
export function isFluentTrigger(element: React_2.ReactElement): element is React_2.ReactElement<TriggerProps>;

// @internal
export function isHTMLElement(element?: Node | null | undefined): element is HTMLElement;
export function isHTMLElement(element?: unknown): element is HTMLElement;

// @internal
export function isInteractiveHTMLElement(element: Node | null | undefined): boolean;
export function isInteractiveHTMLElement(element: unknown): boolean;

// @public
export function isResolvedShorthand<Shorthand extends Slot<UnknownSlotProps>>(shorthand?: Shorthand): shorthand is ExtractSlotProps<Shorthand>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
* might be problematic while operating with [multiple realms](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_realms)
*
*/
export function isHTMLElement(element?: Node | null | undefined): element is HTMLElement {
export function isHTMLElement(element?: unknown): element is HTMLElement {
const typedElement = element as Node | null | undefined;
return Boolean(
element !== null &&
element?.ownerDocument?.defaultView &&
element instanceof element.ownerDocument.defaultView.HTMLElement,
typedElement !== null &&
typedElement?.ownerDocument?.defaultView &&
typedElement instanceof typedElement.ownerDocument.defaultView.HTMLElement,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isHTMLElement } from './isHTMLElement';
* @internal
* Checks that the element has default behaviour from user input on click or 'Enter'/'Space' keys
*/
export function isInteractiveHTMLElement(element: Node | null | undefined) {
export function isInteractiveHTMLElement(element: unknown) {
if (!isHTMLElement(element)) {
return false;
}
Expand Down

0 comments on commit 2d76331

Please sign in to comment.