@wordpress/html-entities 4.32.0 → 4.32.1-next.47f435fc9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +32 -49
- package/build/index.js.map +7 -1
- package/build-module/index.js +11 -46
- package/build-module/index.js.map +7 -1
- package/package.json +10 -5
package/build/index.js
CHANGED
|
@@ -1,62 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
decodeEntities: () => decodeEntities
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
23
|
+
module.exports = __toCommonJS(index_exports);
|
|
7
24
|
let _decodeTextArea;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Decodes the HTML entities from a given string.
|
|
11
|
-
*
|
|
12
|
-
* @param html String that contain HTML entities.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```js
|
|
16
|
-
* import { decodeEntities } from '@wordpress/html-entities';
|
|
17
|
-
*
|
|
18
|
-
* const result = decodeEntities( 'á' );
|
|
19
|
-
* console.log( result ); // result will be "á"
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @return The decoded string.
|
|
23
|
-
*/
|
|
24
25
|
function decodeEntities(html) {
|
|
25
|
-
|
|
26
|
-
// Not a string, or no entities to decode.
|
|
27
|
-
if ('string' !== typeof html || -1 === html.indexOf('&')) {
|
|
26
|
+
if ("string" !== typeof html || -1 === html.indexOf("&")) {
|
|
28
27
|
return html;
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
// Create a textarea for decoding entities, that we can reuse.
|
|
32
|
-
if (undefined === _decodeTextArea) {
|
|
29
|
+
if (void 0 === _decodeTextArea) {
|
|
33
30
|
if (document.implementation && document.implementation.createHTMLDocument) {
|
|
34
|
-
_decodeTextArea = document.implementation.createHTMLDocument(
|
|
31
|
+
_decodeTextArea = document.implementation.createHTMLDocument("").createElement("textarea");
|
|
35
32
|
} else {
|
|
36
|
-
_decodeTextArea = document.createElement(
|
|
33
|
+
_decodeTextArea = document.createElement("textarea");
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
36
|
_decodeTextArea.innerHTML = html;
|
|
40
|
-
const decoded =
|
|
41
|
-
_decodeTextArea.innerHTML =
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Cast to string, HTMLTextAreaElement should always have `string` textContent.
|
|
45
|
-
*
|
|
46
|
-
* > The `textContent` property of the `Node` interface represents the text content of the
|
|
47
|
-
* > node and its descendants.
|
|
48
|
-
* >
|
|
49
|
-
* > Value: A string or `null`
|
|
50
|
-
* >
|
|
51
|
-
* > * If the node is a `document` or a Doctype, `textContent` returns `null`.
|
|
52
|
-
* > * If the node is a CDATA section, comment, processing instruction, or text node,
|
|
53
|
-
* > textContent returns the text inside the node, i.e., the `Node.nodeValue`.
|
|
54
|
-
* > * For other node types, `textContent returns the concatenation of the textContent of
|
|
55
|
-
* > every child node, excluding comments and processing instructions. (This is an empty
|
|
56
|
-
* > string if the node has no children.)
|
|
57
|
-
*
|
|
58
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
|
|
59
|
-
*/
|
|
37
|
+
const decoded = _decodeTextArea.textContent ?? "";
|
|
38
|
+
_decodeTextArea.innerHTML = "";
|
|
60
39
|
return decoded;
|
|
61
40
|
}
|
|
62
|
-
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
decodeEntities
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["let _decodeTextArea: HTMLTextAreaElement | undefined;\n\n/**\n * Decodes the HTML entities from a given string.\n *\n * @param html String that contain HTML entities.\n *\n * @example\n * ```js\n * import { decodeEntities } from '@wordpress/html-entities';\n *\n * const result = decodeEntities( 'á' );\n * console.log( result ); // result will be \"\u00E1\"\n * ```\n *\n * @return The decoded string.\n */\nexport function decodeEntities( html: string ): string {\n\t// Not a string, or no entities to decode.\n\tif ( 'string' !== typeof html || -1 === html.indexOf( '&' ) ) {\n\t\treturn html;\n\t}\n\n\t// Create a textarea for decoding entities, that we can reuse.\n\tif ( undefined === _decodeTextArea ) {\n\t\tif (\n\t\t\tdocument.implementation &&\n\t\t\tdocument.implementation.createHTMLDocument\n\t\t) {\n\t\t\t_decodeTextArea = document.implementation\n\t\t\t\t.createHTMLDocument( '' )\n\t\t\t\t.createElement( 'textarea' );\n\t\t} else {\n\t\t\t_decodeTextArea = document.createElement( 'textarea' );\n\t\t}\n\t}\n\n\t_decodeTextArea.innerHTML = html;\n\tconst decoded = _decodeTextArea.textContent ?? '';\n\t_decodeTextArea.innerHTML = '';\n\n\t/**\n\t * Cast to string, HTMLTextAreaElement should always have `string` textContent.\n\t *\n\t * > The `textContent` property of the `Node` interface represents the text content of the\n\t * > node and its descendants.\n\t * >\n\t * > Value: A string or `null`\n\t * >\n\t * > * If the node is a `document` or a Doctype, `textContent` returns `null`.\n\t * > * If the node is a CDATA section, comment, processing instruction, or text node,\n\t * > textContent returns the text inside the node, i.e., the `Node.nodeValue`.\n\t * > * For other node types, `textContent returns the concatenation of the textContent of\n\t * > every child node, excluding comments and processing instructions. (This is an empty\n\t * > string if the node has no children.)\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent\n\t */\n\treturn decoded;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAI;AAiBG,SAAS,eAAgB,MAAuB;AAEtD,MAAK,aAAa,OAAO,QAAQ,OAAO,KAAK,QAAS,GAAI,GAAI;AAC7D,WAAO;AAAA,EACR;AAGA,MAAK,WAAc,iBAAkB;AACpC,QACC,SAAS,kBACT,SAAS,eAAe,oBACvB;AACD,wBAAkB,SAAS,eACzB,mBAAoB,EAAG,EACvB,cAAe,UAAW;AAAA,IAC7B,OAAO;AACN,wBAAkB,SAAS,cAAe,UAAW;AAAA,IACtD;AAAA,EACD;AAEA,kBAAgB,YAAY;AAC5B,QAAM,UAAU,gBAAgB,eAAe;AAC/C,kBAAgB,YAAY;AAmB5B,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build-module/index.js
CHANGED
|
@@ -1,56 +1,21 @@
|
|
|
1
1
|
let _decodeTextArea;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Decodes the HTML entities from a given string.
|
|
5
|
-
*
|
|
6
|
-
* @param html String that contain HTML entities.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```js
|
|
10
|
-
* import { decodeEntities } from '@wordpress/html-entities';
|
|
11
|
-
*
|
|
12
|
-
* const result = decodeEntities( 'á' );
|
|
13
|
-
* console.log( result ); // result will be "á"
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @return The decoded string.
|
|
17
|
-
*/
|
|
18
|
-
export function decodeEntities(html) {
|
|
19
|
-
var _decodeTextArea$textC;
|
|
20
|
-
// Not a string, or no entities to decode.
|
|
21
|
-
if ('string' !== typeof html || -1 === html.indexOf('&')) {
|
|
2
|
+
function decodeEntities(html) {
|
|
3
|
+
if ("string" !== typeof html || -1 === html.indexOf("&")) {
|
|
22
4
|
return html;
|
|
23
5
|
}
|
|
24
|
-
|
|
25
|
-
// Create a textarea for decoding entities, that we can reuse.
|
|
26
|
-
if (undefined === _decodeTextArea) {
|
|
6
|
+
if (void 0 === _decodeTextArea) {
|
|
27
7
|
if (document.implementation && document.implementation.createHTMLDocument) {
|
|
28
|
-
_decodeTextArea = document.implementation.createHTMLDocument(
|
|
8
|
+
_decodeTextArea = document.implementation.createHTMLDocument("").createElement("textarea");
|
|
29
9
|
} else {
|
|
30
|
-
_decodeTextArea = document.createElement(
|
|
10
|
+
_decodeTextArea = document.createElement("textarea");
|
|
31
11
|
}
|
|
32
12
|
}
|
|
33
13
|
_decodeTextArea.innerHTML = html;
|
|
34
|
-
const decoded =
|
|
35
|
-
_decodeTextArea.innerHTML =
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Cast to string, HTMLTextAreaElement should always have `string` textContent.
|
|
39
|
-
*
|
|
40
|
-
* > The `textContent` property of the `Node` interface represents the text content of the
|
|
41
|
-
* > node and its descendants.
|
|
42
|
-
* >
|
|
43
|
-
* > Value: A string or `null`
|
|
44
|
-
* >
|
|
45
|
-
* > * If the node is a `document` or a Doctype, `textContent` returns `null`.
|
|
46
|
-
* > * If the node is a CDATA section, comment, processing instruction, or text node,
|
|
47
|
-
* > textContent returns the text inside the node, i.e., the `Node.nodeValue`.
|
|
48
|
-
* > * For other node types, `textContent returns the concatenation of the textContent of
|
|
49
|
-
* > every child node, excluding comments and processing instructions. (This is an empty
|
|
50
|
-
* > string if the node has no children.)
|
|
51
|
-
*
|
|
52
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
|
|
53
|
-
*/
|
|
14
|
+
const decoded = _decodeTextArea.textContent ?? "";
|
|
15
|
+
_decodeTextArea.innerHTML = "";
|
|
54
16
|
return decoded;
|
|
55
17
|
}
|
|
56
|
-
|
|
18
|
+
export {
|
|
19
|
+
decodeEntities
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["let _decodeTextArea: HTMLTextAreaElement | undefined;\n\n/**\n * Decodes the HTML entities from a given string.\n *\n * @param html String that contain HTML entities.\n *\n * @example\n * ```js\n * import { decodeEntities } from '@wordpress/html-entities';\n *\n * const result = decodeEntities( 'á' );\n * console.log( result ); // result will be \"\u00E1\"\n * ```\n *\n * @return The decoded string.\n */\nexport function decodeEntities( html: string ): string {\n\t// Not a string, or no entities to decode.\n\tif ( 'string' !== typeof html || -1 === html.indexOf( '&' ) ) {\n\t\treturn html;\n\t}\n\n\t// Create a textarea for decoding entities, that we can reuse.\n\tif ( undefined === _decodeTextArea ) {\n\t\tif (\n\t\t\tdocument.implementation &&\n\t\t\tdocument.implementation.createHTMLDocument\n\t\t) {\n\t\t\t_decodeTextArea = document.implementation\n\t\t\t\t.createHTMLDocument( '' )\n\t\t\t\t.createElement( 'textarea' );\n\t\t} else {\n\t\t\t_decodeTextArea = document.createElement( 'textarea' );\n\t\t}\n\t}\n\n\t_decodeTextArea.innerHTML = html;\n\tconst decoded = _decodeTextArea.textContent ?? '';\n\t_decodeTextArea.innerHTML = '';\n\n\t/**\n\t * Cast to string, HTMLTextAreaElement should always have `string` textContent.\n\t *\n\t * > The `textContent` property of the `Node` interface represents the text content of the\n\t * > node and its descendants.\n\t * >\n\t * > Value: A string or `null`\n\t * >\n\t * > * If the node is a `document` or a Doctype, `textContent` returns `null`.\n\t * > * If the node is a CDATA section, comment, processing instruction, or text node,\n\t * > textContent returns the text inside the node, i.e., the `Node.nodeValue`.\n\t * > * For other node types, `textContent returns the concatenation of the textContent of\n\t * > every child node, excluding comments and processing instructions. (This is an empty\n\t * > string if the node has no children.)\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent\n\t */\n\treturn decoded;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,IAAI;AAiBG,SAAS,eAAgB,MAAuB;AAEtD,MAAK,aAAa,OAAO,QAAQ,OAAO,KAAK,QAAS,GAAI,GAAI;AAC7D,WAAO;AAAA,EACR;AAGA,MAAK,WAAc,iBAAkB;AACpC,QACC,SAAS,kBACT,SAAS,eAAe,oBACvB;AACD,wBAAkB,SAAS,eACzB,mBAAoB,EAAG,EACvB,cAAe,UAAW;AAAA,IAC7B,OAAO;AACN,wBAAkB,SAAS,cAAe,UAAW;AAAA,IACtD;AAAA,EACD;AAEA,kBAAgB,YAAY;AAC5B,QAAM,UAAU,gBAAgB,eAAe;AAC/C,kBAAgB,YAAY;AAmB5B,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/html-entities",
|
|
3
|
-
"version": "4.32.0",
|
|
3
|
+
"version": "4.32.1-next.47f435fc9.0",
|
|
4
4
|
"description": "HTML entity utilities for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -25,14 +25,19 @@
|
|
|
25
25
|
},
|
|
26
26
|
"main": "build/index.js",
|
|
27
27
|
"module": "build-module/index.js",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./build-types/index.d.ts",
|
|
31
|
+
"import": "./build-module/index.js",
|
|
32
|
+
"require": "./build/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
28
36
|
"react-native": "src/index",
|
|
29
37
|
"wpScript": true,
|
|
30
38
|
"types": "build-types",
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@babel/runtime": "7.25.7"
|
|
33
|
-
},
|
|
34
39
|
"publishConfig": {
|
|
35
40
|
"access": "public"
|
|
36
41
|
},
|
|
37
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "9720f22c138771d2ed1a0522725c3cdf1c242953"
|
|
38
43
|
}
|