Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/utilities",
"comment": "Mark setPortalAttribute dom utility function as public to fix undefined runtime error.",
"type": "patch"
}
],
"packageName": "@uifabric/utilities",
"email": "[email protected]"
}
17 changes: 4 additions & 13 deletions packages/utilities/src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ export function getVirtualParent(child: HTMLElement): HTMLElement | undefined {
* @public
*/
export function getParent(child: HTMLElement, allowVirtualParents: boolean = true): HTMLElement | null {
return (
child &&
((allowVirtualParents && getVirtualParent(child)) || (child.parentNode && (child.parentNode as HTMLElement)))
);
return child && ((allowVirtualParents && getVirtualParent(child)) || (child.parentNode && (child.parentNode as HTMLElement)));
}

/**
Expand Down Expand Up @@ -112,11 +109,7 @@ export function getChildren(parent: HTMLElement, allowVirtualChildren: boolean =
*
* @public
*/
export function elementContains(
parent: HTMLElement | null,
child: HTMLElement | null,
allowVirtualParents: boolean = true
): boolean {
export function elementContains(parent: HTMLElement | null, child: HTMLElement | null, allowVirtualParents: boolean = true): boolean {
let isContained = false;

if (parent && child) {
Expand Down Expand Up @@ -209,6 +202,7 @@ export function getRect(element: HTMLElement | Window | null): IRectangle | unde
/**
* Identify element as a portal by setting an attribute.
* @param element Element to mark as a portal.
* @public
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the "fix"

Copy link
Member

@JasonGore JasonGore Sep 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused how a jsdoc tag removes a runtime error? Are you sure this error wasn't due to a local build error (i.e. utilities package was out of date)? I've never seen this error while developing and testing portals and don't see it locally now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're probably right that it was rush and my local setup. Closing this with the real focus fix in #6308

*/
export function setPortalAttribute(element: HTMLElement): void {
element.setAttribute(DATA_PORTAL_ATTRIBUTE, 'true');
Expand All @@ -235,10 +229,7 @@ export function portalContainsElement(target: HTMLElement, parent?: HTMLElement)
* @param matchFunction the function that determines if the element is a match
* @returns the matched element or null no match was found
*/
export function findElementRecursive(
element: HTMLElement | null,
matchFunction: (element: HTMLElement) => boolean
): HTMLElement | null {
export function findElementRecursive(element: HTMLElement | null, matchFunction: (element: HTMLElement) => boolean): HTMLElement | null {
if (!element || element === document.body) {
return null;
}
Expand Down