UNPKG

@gitlab/ui

Version:
17 lines (13 loc) 534 B
import { RX_HTML_TAGS } from '../constants/regex'; // Removes anything that looks like an HTML tag from the supplied string const stripTags = function () { let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; return String(text).replace(RX_HTML_TAGS, ''); }; // Generate a `domProps` object for either `innerHTML`, `textContent` or an empty object const htmlOrText = (innerHTML, textContent) => innerHTML ? { innerHTML } : textContent ? { textContent } : {}; export { htmlOrText, stripTags };