Skip to content

Commit

Permalink
checkbox: use util func
Browse files Browse the repository at this point in the history
  • Loading branch information
chaance committed Feb 11, 2020
1 parent 35e59c6 commit 859144f
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions packages/tabs/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import {
cloneValidElement,
createNamedContext,
forwardRefWithAs,
isFunction,
getElementComputedStyle,
isNumber,
makeId,
noop,
Expand Down Expand Up @@ -289,7 +289,7 @@ export const TabList = forwardRefWithAs<TabListProps, "div">(function TabList(
ownRef.current &&
((ownRef.current.ownerDocument &&
ownRef.current.ownerDocument.dir === "rtl") ||
getStyle(ownRef.current, "direction") === "rtl")
getElementComputedStyle(ownRef.current, "direction") === "rtl")
) {
isRTL.current = true;
}
Expand Down Expand Up @@ -624,31 +624,3 @@ if (__DEV__) {
children: PropTypes.node,
};
}

/**
* Get a computed style value by property, backwards compatible with IE
* @param element
* @param styleProp
*/
function getStyle(element: HTMLElementWithCurrentStyle, styleProp: string) {
let y: string | null = null;
if (element.currentStyle) {
y = element.currentStyle[styleProp];
} else if (
element.ownerDocument &&
element.ownerDocument.defaultView &&
isFunction(element.ownerDocument.defaultView.getComputedStyle)
) {
y = element.ownerDocument.defaultView
.getComputedStyle(element, null)
.getPropertyValue(styleProp);
}
return y;
}

////////////////////////////////////////////////////////////////////////////////
// Types

type HTMLElementWithCurrentStyle = HTMLElement & {
currentStyle?: Record<string, string>;
};

0 comments on commit 859144f

Please sign in to comment.