azure-devops-ui
Version:
React components for building web UI in Azure DevOps
28 lines (27 loc) • 915 B
JavaScript
/**
* Handles an href and target being passed to an anchor, without a rel.
*/
export function getDefaultAnchorProps(anchorProps) {
let modifiedAnchorProps;
if (anchorProps) {
let rel = anchorProps.rel;
if (anchorProps.href && anchorProps.target && !rel) {
rel = "noopener";
}
modifiedAnchorProps = {
href: anchorProps.href,
rel: rel,
target: anchorProps.target
};
}
return modifiedAnchorProps;
}
/**
* Handles an href and target being passed to a link, without a rel.
*/
export function getDefaultLinkProps(linkProps) {
if (!linkProps) {
return getDefaultAnchorProps(linkProps);
}
return Object.assign(Object.assign({}, getDefaultAnchorProps(linkProps)), { disabled: linkProps.disabled, id: linkProps.id, onClick: linkProps.onClick, role: linkProps.role });
}