1 /******/ (function() { // webpackBootstrap |
1 /******/ (() => { // webpackBootstrap |
2 /******/ "use strict"; |
2 /******/ "use strict"; |
3 /******/ // The require scope |
3 /******/ // The require scope |
4 /******/ var __webpack_require__ = {}; |
4 /******/ var __webpack_require__ = {}; |
5 /******/ |
5 /******/ |
6 /************************************************************************/ |
6 /************************************************************************/ |
7 /******/ /* webpack/runtime/define property getters */ |
7 /******/ /* webpack/runtime/define property getters */ |
8 /******/ !function() { |
8 /******/ (() => { |
9 /******/ // define getter functions for harmony exports |
9 /******/ // define getter functions for harmony exports |
10 /******/ __webpack_require__.d = function(exports, definition) { |
10 /******/ __webpack_require__.d = (exports, definition) => { |
11 /******/ for(var key in definition) { |
11 /******/ for(var key in definition) { |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
14 /******/ } |
14 /******/ } |
15 /******/ } |
15 /******/ } |
16 /******/ }; |
16 /******/ }; |
17 /******/ }(); |
17 /******/ })(); |
18 /******/ |
18 /******/ |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
20 /******/ !function() { |
20 /******/ (() => { |
21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
22 /******/ }(); |
22 /******/ })(); |
23 /******/ |
23 /******/ |
24 /******/ /* webpack/runtime/make namespace object */ |
24 /******/ /* webpack/runtime/make namespace object */ |
25 /******/ !function() { |
25 /******/ (() => { |
26 /******/ // define __esModule on exports |
26 /******/ // define __esModule on exports |
27 /******/ __webpack_require__.r = function(exports) { |
27 /******/ __webpack_require__.r = (exports) => { |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
30 /******/ } |
30 /******/ } |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
32 /******/ }; |
32 /******/ }; |
33 /******/ }(); |
33 /******/ })(); |
34 /******/ |
34 /******/ |
35 /************************************************************************/ |
35 /************************************************************************/ |
36 var __webpack_exports__ = {}; |
36 var __webpack_exports__ = {}; |
37 __webpack_require__.r(__webpack_exports__); |
37 __webpack_require__.r(__webpack_exports__); |
38 /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
38 /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
39 /* harmony export */ "decodeEntities": function() { return /* binding */ decodeEntities; } |
39 /* harmony export */ decodeEntities: () => (/* binding */ decodeEntities) |
40 /* harmony export */ }); |
40 /* harmony export */ }); |
41 /** @type {HTMLTextAreaElement} */ |
41 /** @type {HTMLTextAreaElement} */ |
42 let _decodeTextArea; |
42 let _decodeTextArea; |
|
43 |
43 /** |
44 /** |
44 * Decodes the HTML entities from a given string. |
45 * Decodes the HTML entities from a given string. |
45 * |
46 * |
46 * @param {string} html String that contain HTML entities. |
47 * @param {string} html String that contain HTML entities. |
47 * |
48 * |
48 * @example |
49 * @example |
49 * ```js |
50 * ```js |
|
51 * import { decodeEntities } from '@wordpress/html-entities'; |
|
52 * |
50 * const result = decodeEntities( 'á' ); |
53 * const result = decodeEntities( 'á' ); |
51 * console.log( result ); // result will be "á" |
54 * console.log( result ); // result will be "á" |
52 * ``` |
55 * ``` |
53 * |
56 * |
54 * @return {string} The decoded string. |
57 * @return {string} The decoded string. |
55 */ |
58 */ |
56 |
|
57 |
|
58 function decodeEntities(html) { |
59 function decodeEntities(html) { |
59 // Not a string, or no entities to decode. |
60 // Not a string, or no entities to decode. |
60 if ('string' !== typeof html || -1 === html.indexOf('&')) { |
61 if ('string' !== typeof html || -1 === html.indexOf('&')) { |
61 return html; |
62 return html; |
62 } // Create a textarea for decoding entities, that we can reuse. |
63 } |
63 |
64 |
64 |
65 // Create a textarea for decoding entities, that we can reuse. |
65 if (undefined === _decodeTextArea) { |
66 if (undefined === _decodeTextArea) { |
66 if (document.implementation && document.implementation.createHTMLDocument) { |
67 if (document.implementation && document.implementation.createHTMLDocument) { |
67 _decodeTextArea = document.implementation.createHTMLDocument('').createElement('textarea'); |
68 _decodeTextArea = document.implementation.createHTMLDocument('').createElement('textarea'); |
68 } else { |
69 } else { |
69 _decodeTextArea = document.createElement('textarea'); |
70 _decodeTextArea = document.createElement('textarea'); |
70 } |
71 } |
71 } |
72 } |
72 |
|
73 _decodeTextArea.innerHTML = html; |
73 _decodeTextArea.innerHTML = html; |
74 const decoded = _decodeTextArea.textContent; |
74 const decoded = _decodeTextArea.textContent; |
75 _decodeTextArea.innerHTML = ''; |
75 _decodeTextArea.innerHTML = ''; |
|
76 |
76 /** |
77 /** |
77 * Cast to string, HTMLTextAreaElement should always have `string` textContent. |
78 * Cast to string, HTMLTextAreaElement should always have `string` textContent. |
78 * |
79 * |
79 * > The `textContent` property of the `Node` interface represents the text content of the |
80 * > The `textContent` property of the `Node` interface represents the text content of the |
80 * > node and its descendants. |
81 * > node and its descendants. |