UNPKG

@wordpress/dom

Version:
28 lines (26 loc) 836 B
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = stripHTML; var _safeHtml = _interopRequireDefault(require("./safe-html")); /** * Internal dependencies */ /** * Removes any HTML tags from the provided string. * * @param {string} html The string containing html. * * @return {string} The text content with any html removed. */ function stripHTML(html) { // Remove any script tags or on* attributes otherwise their *contents* will be left // in place following removal of HTML tags. html = (0, _safeHtml.default)(html); const doc = document.implementation.createHTMLDocument(''); doc.body.innerHTML = html; return doc.body.textContent || ''; } //# sourceMappingURL=strip-html.js.map