@wordpress/element 6.32.0 → 6.32.1-next.b8c8708f3.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/create-interpolate-element.js +79 -183
- package/build/create-interpolate-element.js.map +7 -1
- package/build/index.js +52 -74
- package/build/index.js.map +7 -1
- package/build/platform.android.js +29 -16
- package/build/platform.android.js.map +7 -1
- package/build/platform.ios.js +29 -16
- package/build/platform.ios.js.map +7 -1
- package/build/platform.js +25 -40
- package/build/platform.js.map +7 -1
- package/build/raw-html.js +28 -47
- package/build/raw-html.js.map +7 -1
- package/build/react-platform.js +43 -55
- package/build/react-platform.js.map +7 -1
- package/build/react.js +114 -411
- package/build/react.js.map +7 -1
- package/build/serialize.js +418 -325
- package/build/serialize.js.map +7 -1
- package/build/utils.js +29 -15
- package/build/utils.js.map +7 -1
- package/build-module/create-interpolate-element.js +63 -175
- package/build-module/create-interpolate-element.js.map +7 -1
- package/build-module/index.js +14 -8
- package/build-module/index.js.map +7 -1
- package/build-module/platform.android.js +10 -10
- package/build-module/platform.android.js.map +7 -1
- package/build-module/platform.ios.js +10 -10
- package/build-module/platform.ios.js.map +7 -1
- package/build-module/platform.js +7 -36
- package/build-module/platform.js.map +7 -1
- package/build-module/raw-html.js +11 -44
- package/build-module/raw-html.js.map +7 -1
- package/build-module/react-platform.js +20 -71
- package/build-module/react-platform.js.map +7 -1
- package/build-module/react.js +91 -255
- package/build-module/react.js.map +7 -1
- package/build-module/serialize.js +382 -311
- package/build-module/serialize.js.map +7 -1
- package/build-module/utils.js +7 -10
- package/build-module/utils.js.map +7 -1
- package/package.json +11 -4
- package/build/react-platform.native.js +0 -22
- package/build/react-platform.native.js.map +0 -1
- package/build-module/react-platform.native.js +0 -15
- package/build-module/react-platform.native.js.map +0 -1
package/build/serialize.js
CHANGED
|
@@ -1,335 +1,456 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var serialize_exports = {};
|
|
30
|
+
__export(serialize_exports, {
|
|
31
|
+
default: () => serialize_default,
|
|
32
|
+
hasPrefix: () => hasPrefix,
|
|
33
|
+
renderAttributes: () => renderAttributes,
|
|
34
|
+
renderComponent: () => renderComponent,
|
|
35
|
+
renderElement: () => renderElement,
|
|
36
|
+
renderNativeComponent: () => renderNativeComponent,
|
|
37
|
+
renderStyle: () => renderStyle
|
|
6
38
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _react = require("./react");
|
|
18
|
-
var _rawHtml = _interopRequireDefault(require("./raw-html"));
|
|
19
|
-
/**
|
|
20
|
-
* Parts of this source were derived and modified from fast-react-render,
|
|
21
|
-
* released under the MIT license.
|
|
22
|
-
*
|
|
23
|
-
* https://github.com/alt-j/fast-react-render
|
|
24
|
-
*
|
|
25
|
-
* Copyright (c) 2016 Andrey Morozov
|
|
26
|
-
*
|
|
27
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
29
|
-
* in the Software without restriction, including without limitation the rights
|
|
30
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
32
|
-
* furnished to do so, subject to the following conditions:
|
|
33
|
-
*
|
|
34
|
-
* The above copyright notice and this permission notice shall be included in
|
|
35
|
-
* all copies or substantial portions of the Software.
|
|
36
|
-
*
|
|
37
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
43
|
-
* THE SOFTWARE.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* External dependencies
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* WordPress dependencies
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Internal dependencies
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/** @typedef {import('react').ReactElement} ReactElement */
|
|
59
|
-
|
|
60
|
-
const Context = (0, _react.createContext)(undefined);
|
|
61
|
-
Context.displayName = 'ElementContext';
|
|
62
|
-
const {
|
|
63
|
-
Provider,
|
|
64
|
-
Consumer
|
|
65
|
-
} = Context;
|
|
66
|
-
const ForwardRef = (0, _react.forwardRef)(() => {
|
|
39
|
+
module.exports = __toCommonJS(serialize_exports);
|
|
40
|
+
var import_is_plain_object = require("is-plain-object");
|
|
41
|
+
var import_change_case = require("change-case");
|
|
42
|
+
var import_escape_html = require("@wordpress/escape-html");
|
|
43
|
+
var import_react = require("./react");
|
|
44
|
+
var import_raw_html = __toESM(require("./raw-html"));
|
|
45
|
+
const Context = (0, import_react.createContext)(void 0);
|
|
46
|
+
Context.displayName = "ElementContext";
|
|
47
|
+
const { Provider, Consumer } = Context;
|
|
48
|
+
const ForwardRef = (0, import_react.forwardRef)(() => {
|
|
67
49
|
return null;
|
|
68
50
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
51
|
+
const ATTRIBUTES_TYPES = /* @__PURE__ */ new Set(["string", "boolean", "number"]);
|
|
52
|
+
const SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([
|
|
53
|
+
"area",
|
|
54
|
+
"base",
|
|
55
|
+
"br",
|
|
56
|
+
"col",
|
|
57
|
+
"command",
|
|
58
|
+
"embed",
|
|
59
|
+
"hr",
|
|
60
|
+
"img",
|
|
61
|
+
"input",
|
|
62
|
+
"keygen",
|
|
63
|
+
"link",
|
|
64
|
+
"meta",
|
|
65
|
+
"param",
|
|
66
|
+
"source",
|
|
67
|
+
"track",
|
|
68
|
+
"wbr"
|
|
69
|
+
]);
|
|
70
|
+
const BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
71
|
+
"allowfullscreen",
|
|
72
|
+
"allowpaymentrequest",
|
|
73
|
+
"allowusermedia",
|
|
74
|
+
"async",
|
|
75
|
+
"autofocus",
|
|
76
|
+
"autoplay",
|
|
77
|
+
"checked",
|
|
78
|
+
"controls",
|
|
79
|
+
"default",
|
|
80
|
+
"defer",
|
|
81
|
+
"disabled",
|
|
82
|
+
"download",
|
|
83
|
+
"formnovalidate",
|
|
84
|
+
"hidden",
|
|
85
|
+
"ismap",
|
|
86
|
+
"itemscope",
|
|
87
|
+
"loop",
|
|
88
|
+
"multiple",
|
|
89
|
+
"muted",
|
|
90
|
+
"nomodule",
|
|
91
|
+
"novalidate",
|
|
92
|
+
"open",
|
|
93
|
+
"playsinline",
|
|
94
|
+
"readonly",
|
|
95
|
+
"required",
|
|
96
|
+
"reversed",
|
|
97
|
+
"selected",
|
|
98
|
+
"typemustmatch"
|
|
99
|
+
]);
|
|
100
|
+
const ENUMERATED_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
101
|
+
"autocapitalize",
|
|
102
|
+
"autocomplete",
|
|
103
|
+
"charset",
|
|
104
|
+
"contenteditable",
|
|
105
|
+
"crossorigin",
|
|
106
|
+
"decoding",
|
|
107
|
+
"dir",
|
|
108
|
+
"draggable",
|
|
109
|
+
"enctype",
|
|
110
|
+
"formenctype",
|
|
111
|
+
"formmethod",
|
|
112
|
+
"http-equiv",
|
|
113
|
+
"inputmode",
|
|
114
|
+
"kind",
|
|
115
|
+
"method",
|
|
116
|
+
"preload",
|
|
117
|
+
"scope",
|
|
118
|
+
"shape",
|
|
119
|
+
"spellcheck",
|
|
120
|
+
"translate",
|
|
121
|
+
"type",
|
|
122
|
+
"wrap"
|
|
123
|
+
]);
|
|
124
|
+
const CSS_PROPERTIES_SUPPORTS_UNITLESS = /* @__PURE__ */ new Set([
|
|
125
|
+
"animation",
|
|
126
|
+
"animationIterationCount",
|
|
127
|
+
"baselineShift",
|
|
128
|
+
"borderImageOutset",
|
|
129
|
+
"borderImageSlice",
|
|
130
|
+
"borderImageWidth",
|
|
131
|
+
"columnCount",
|
|
132
|
+
"cx",
|
|
133
|
+
"cy",
|
|
134
|
+
"fillOpacity",
|
|
135
|
+
"flexGrow",
|
|
136
|
+
"flexShrink",
|
|
137
|
+
"floodOpacity",
|
|
138
|
+
"fontWeight",
|
|
139
|
+
"gridColumnEnd",
|
|
140
|
+
"gridColumnStart",
|
|
141
|
+
"gridRowEnd",
|
|
142
|
+
"gridRowStart",
|
|
143
|
+
"lineHeight",
|
|
144
|
+
"opacity",
|
|
145
|
+
"order",
|
|
146
|
+
"orphans",
|
|
147
|
+
"r",
|
|
148
|
+
"rx",
|
|
149
|
+
"ry",
|
|
150
|
+
"shapeImageThreshold",
|
|
151
|
+
"stopOpacity",
|
|
152
|
+
"strokeDasharray",
|
|
153
|
+
"strokeDashoffset",
|
|
154
|
+
"strokeMiterlimit",
|
|
155
|
+
"strokeOpacity",
|
|
156
|
+
"strokeWidth",
|
|
157
|
+
"tabSize",
|
|
158
|
+
"widows",
|
|
159
|
+
"x",
|
|
160
|
+
"y",
|
|
161
|
+
"zIndex",
|
|
162
|
+
"zoom"
|
|
163
|
+
]);
|
|
139
164
|
function hasPrefix(string, prefixes) {
|
|
140
|
-
return prefixes.some(prefix => string.indexOf(prefix) === 0);
|
|
165
|
+
return prefixes.some((prefix) => string.indexOf(prefix) === 0);
|
|
141
166
|
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Returns true if the given prop name should be ignored in attributes
|
|
145
|
-
* serialization, or false otherwise.
|
|
146
|
-
* @param attribute
|
|
147
|
-
*/
|
|
148
167
|
function isInternalAttribute(attribute) {
|
|
149
|
-
return
|
|
168
|
+
return "key" === attribute || "children" === attribute;
|
|
150
169
|
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Returns the normal form of the element's attribute value for HTML.
|
|
154
|
-
* @param attribute
|
|
155
|
-
* @param value
|
|
156
|
-
*/
|
|
157
170
|
function getNormalAttributeValue(attribute, value) {
|
|
158
171
|
switch (attribute) {
|
|
159
|
-
case
|
|
172
|
+
case "style":
|
|
160
173
|
return renderStyle(value);
|
|
161
174
|
}
|
|
162
175
|
return value;
|
|
163
176
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
177
|
+
const SVG_ATTRIBUTE_WITH_DASHES_LIST = [
|
|
178
|
+
"accentHeight",
|
|
179
|
+
"alignmentBaseline",
|
|
180
|
+
"arabicForm",
|
|
181
|
+
"baselineShift",
|
|
182
|
+
"capHeight",
|
|
183
|
+
"clipPath",
|
|
184
|
+
"clipRule",
|
|
185
|
+
"colorInterpolation",
|
|
186
|
+
"colorInterpolationFilters",
|
|
187
|
+
"colorProfile",
|
|
188
|
+
"colorRendering",
|
|
189
|
+
"dominantBaseline",
|
|
190
|
+
"enableBackground",
|
|
191
|
+
"fillOpacity",
|
|
192
|
+
"fillRule",
|
|
193
|
+
"floodColor",
|
|
194
|
+
"floodOpacity",
|
|
195
|
+
"fontFamily",
|
|
196
|
+
"fontSize",
|
|
197
|
+
"fontSizeAdjust",
|
|
198
|
+
"fontStretch",
|
|
199
|
+
"fontStyle",
|
|
200
|
+
"fontVariant",
|
|
201
|
+
"fontWeight",
|
|
202
|
+
"glyphName",
|
|
203
|
+
"glyphOrientationHorizontal",
|
|
204
|
+
"glyphOrientationVertical",
|
|
205
|
+
"horizAdvX",
|
|
206
|
+
"horizOriginX",
|
|
207
|
+
"imageRendering",
|
|
208
|
+
"letterSpacing",
|
|
209
|
+
"lightingColor",
|
|
210
|
+
"markerEnd",
|
|
211
|
+
"markerMid",
|
|
212
|
+
"markerStart",
|
|
213
|
+
"overlinePosition",
|
|
214
|
+
"overlineThickness",
|
|
215
|
+
"paintOrder",
|
|
216
|
+
"panose1",
|
|
217
|
+
"pointerEvents",
|
|
218
|
+
"renderingIntent",
|
|
219
|
+
"shapeRendering",
|
|
220
|
+
"stopColor",
|
|
221
|
+
"stopOpacity",
|
|
222
|
+
"strikethroughPosition",
|
|
223
|
+
"strikethroughThickness",
|
|
224
|
+
"strokeDasharray",
|
|
225
|
+
"strokeDashoffset",
|
|
226
|
+
"strokeLinecap",
|
|
227
|
+
"strokeLinejoin",
|
|
228
|
+
"strokeMiterlimit",
|
|
229
|
+
"strokeOpacity",
|
|
230
|
+
"strokeWidth",
|
|
231
|
+
"textAnchor",
|
|
232
|
+
"textDecoration",
|
|
233
|
+
"textRendering",
|
|
234
|
+
"underlinePosition",
|
|
235
|
+
"underlineThickness",
|
|
236
|
+
"unicodeBidi",
|
|
237
|
+
"unicodeRange",
|
|
238
|
+
"unitsPerEm",
|
|
239
|
+
"vAlphabetic",
|
|
240
|
+
"vHanging",
|
|
241
|
+
"vIdeographic",
|
|
242
|
+
"vMathematical",
|
|
243
|
+
"vectorEffect",
|
|
244
|
+
"vertAdvY",
|
|
245
|
+
"vertOriginX",
|
|
246
|
+
"vertOriginY",
|
|
247
|
+
"wordSpacing",
|
|
248
|
+
"writingMode",
|
|
249
|
+
"xmlnsXlink",
|
|
250
|
+
"xHeight"
|
|
251
|
+
].reduce(
|
|
252
|
+
(map, attribute) => {
|
|
253
|
+
map[attribute.toLowerCase()] = attribute;
|
|
254
|
+
return map;
|
|
255
|
+
},
|
|
256
|
+
{}
|
|
257
|
+
);
|
|
258
|
+
const CASE_SENSITIVE_SVG_ATTRIBUTES = [
|
|
259
|
+
"allowReorder",
|
|
260
|
+
"attributeName",
|
|
261
|
+
"attributeType",
|
|
262
|
+
"autoReverse",
|
|
263
|
+
"baseFrequency",
|
|
264
|
+
"baseProfile",
|
|
265
|
+
"calcMode",
|
|
266
|
+
"clipPathUnits",
|
|
267
|
+
"contentScriptType",
|
|
268
|
+
"contentStyleType",
|
|
269
|
+
"diffuseConstant",
|
|
270
|
+
"edgeMode",
|
|
271
|
+
"externalResourcesRequired",
|
|
272
|
+
"filterRes",
|
|
273
|
+
"filterUnits",
|
|
274
|
+
"glyphRef",
|
|
275
|
+
"gradientTransform",
|
|
276
|
+
"gradientUnits",
|
|
277
|
+
"kernelMatrix",
|
|
278
|
+
"kernelUnitLength",
|
|
279
|
+
"keyPoints",
|
|
280
|
+
"keySplines",
|
|
281
|
+
"keyTimes",
|
|
282
|
+
"lengthAdjust",
|
|
283
|
+
"limitingConeAngle",
|
|
284
|
+
"markerHeight",
|
|
285
|
+
"markerUnits",
|
|
286
|
+
"markerWidth",
|
|
287
|
+
"maskContentUnits",
|
|
288
|
+
"maskUnits",
|
|
289
|
+
"numOctaves",
|
|
290
|
+
"pathLength",
|
|
291
|
+
"patternContentUnits",
|
|
292
|
+
"patternTransform",
|
|
293
|
+
"patternUnits",
|
|
294
|
+
"pointsAtX",
|
|
295
|
+
"pointsAtY",
|
|
296
|
+
"pointsAtZ",
|
|
297
|
+
"preserveAlpha",
|
|
298
|
+
"preserveAspectRatio",
|
|
299
|
+
"primitiveUnits",
|
|
300
|
+
"refX",
|
|
301
|
+
"refY",
|
|
302
|
+
"repeatCount",
|
|
303
|
+
"repeatDur",
|
|
304
|
+
"requiredExtensions",
|
|
305
|
+
"requiredFeatures",
|
|
306
|
+
"specularConstant",
|
|
307
|
+
"specularExponent",
|
|
308
|
+
"spreadMethod",
|
|
309
|
+
"startOffset",
|
|
310
|
+
"stdDeviation",
|
|
311
|
+
"stitchTiles",
|
|
312
|
+
"suppressContentEditableWarning",
|
|
313
|
+
"suppressHydrationWarning",
|
|
314
|
+
"surfaceScale",
|
|
315
|
+
"systemLanguage",
|
|
316
|
+
"tableValues",
|
|
317
|
+
"targetX",
|
|
318
|
+
"targetY",
|
|
319
|
+
"textLength",
|
|
320
|
+
"viewBox",
|
|
321
|
+
"viewTarget",
|
|
322
|
+
"xChannelSelector",
|
|
323
|
+
"yChannelSelector"
|
|
324
|
+
].reduce(
|
|
325
|
+
(map, attribute) => {
|
|
326
|
+
map[attribute.toLowerCase()] = attribute;
|
|
327
|
+
return map;
|
|
328
|
+
},
|
|
329
|
+
{}
|
|
330
|
+
);
|
|
331
|
+
const SVG_ATTRIBUTES_WITH_COLONS = [
|
|
332
|
+
"xlink:actuate",
|
|
333
|
+
"xlink:arcrole",
|
|
334
|
+
"xlink:href",
|
|
335
|
+
"xlink:role",
|
|
336
|
+
"xlink:show",
|
|
337
|
+
"xlink:title",
|
|
338
|
+
"xlink:type",
|
|
339
|
+
"xml:base",
|
|
340
|
+
"xml:lang",
|
|
341
|
+
"xml:space",
|
|
342
|
+
"xmlns:xlink"
|
|
343
|
+
].reduce(
|
|
344
|
+
(map, attribute) => {
|
|
345
|
+
map[attribute.replace(":", "").toLowerCase()] = attribute;
|
|
346
|
+
return map;
|
|
347
|
+
},
|
|
348
|
+
{}
|
|
349
|
+
);
|
|
202
350
|
function getNormalAttributeName(attribute) {
|
|
203
351
|
switch (attribute) {
|
|
204
|
-
case
|
|
205
|
-
return
|
|
206
|
-
case
|
|
207
|
-
return
|
|
352
|
+
case "htmlFor":
|
|
353
|
+
return "for";
|
|
354
|
+
case "className":
|
|
355
|
+
return "class";
|
|
208
356
|
}
|
|
209
357
|
const attributeLowerCase = attribute.toLowerCase();
|
|
210
358
|
if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
|
|
211
359
|
return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
|
|
212
360
|
} else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
|
|
213
|
-
return (0,
|
|
361
|
+
return (0, import_change_case.paramCase)(
|
|
362
|
+
SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]
|
|
363
|
+
);
|
|
214
364
|
} else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
|
|
215
365
|
return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
|
|
216
366
|
}
|
|
217
367
|
return attributeLowerCase;
|
|
218
368
|
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Returns the normal form of the style property name for HTML.
|
|
222
|
-
*
|
|
223
|
-
* - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'
|
|
224
|
-
* - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'
|
|
225
|
-
* - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'
|
|
226
|
-
* @param property
|
|
227
|
-
*/
|
|
228
369
|
function getNormalStylePropertyName(property) {
|
|
229
|
-
if (property.startsWith(
|
|
370
|
+
if (property.startsWith("--")) {
|
|
230
371
|
return property;
|
|
231
372
|
}
|
|
232
|
-
if (hasPrefix(property, [
|
|
233
|
-
return
|
|
373
|
+
if (hasPrefix(property, ["ms", "O", "Moz", "Webkit"])) {
|
|
374
|
+
return "-" + (0, import_change_case.paramCase)(property);
|
|
234
375
|
}
|
|
235
|
-
return (0,
|
|
376
|
+
return (0, import_change_case.paramCase)(property);
|
|
236
377
|
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Returns the normal form of the style property value for HTML. Appends a
|
|
240
|
-
* default pixel unit if numeric, not a unitless property, and not zero.
|
|
241
|
-
* @param property
|
|
242
|
-
* @param value
|
|
243
|
-
*/
|
|
244
378
|
function getNormalStylePropertyValue(property, value) {
|
|
245
|
-
if (typeof value ===
|
|
246
|
-
return value +
|
|
379
|
+
if (typeof value === "number" && 0 !== value && !hasPrefix(property, ["--"]) && !CSS_PROPERTIES_SUPPORTS_UNITLESS.has(property)) {
|
|
380
|
+
return value + "px";
|
|
247
381
|
}
|
|
248
382
|
return value;
|
|
249
383
|
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Serializes a React element to string.
|
|
253
|
-
* @param element
|
|
254
|
-
* @param context
|
|
255
|
-
* @param legacyContext
|
|
256
|
-
*/
|
|
257
384
|
function renderElement(element, context, legacyContext = {}) {
|
|
258
|
-
if (null === element ||
|
|
259
|
-
return
|
|
385
|
+
if (null === element || void 0 === element || false === element) {
|
|
386
|
+
return "";
|
|
260
387
|
}
|
|
261
388
|
if (Array.isArray(element)) {
|
|
262
389
|
return renderChildren(element, context, legacyContext);
|
|
263
390
|
}
|
|
264
391
|
switch (typeof element) {
|
|
265
|
-
case
|
|
266
|
-
return (0,
|
|
267
|
-
case
|
|
392
|
+
case "string":
|
|
393
|
+
return (0, import_escape_html.escapeHTML)(element);
|
|
394
|
+
case "number":
|
|
268
395
|
return element.toString();
|
|
269
396
|
}
|
|
270
|
-
const {
|
|
271
|
-
type,
|
|
272
|
-
props
|
|
273
|
-
} = element;
|
|
397
|
+
const { type, props } = element;
|
|
274
398
|
switch (type) {
|
|
275
|
-
case
|
|
276
|
-
case
|
|
399
|
+
case import_react.StrictMode:
|
|
400
|
+
case import_react.Fragment:
|
|
277
401
|
return renderChildren(props.children, context, legacyContext);
|
|
278
|
-
case
|
|
279
|
-
const {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
402
|
+
case import_raw_html.default:
|
|
403
|
+
const { children, ...wrapperProps } = props;
|
|
404
|
+
return renderNativeComponent(
|
|
405
|
+
!Object.keys(wrapperProps).length ? null : "div",
|
|
406
|
+
{
|
|
407
|
+
...wrapperProps,
|
|
408
|
+
dangerouslySetInnerHTML: { __html: children }
|
|
409
|
+
},
|
|
410
|
+
context,
|
|
411
|
+
legacyContext
|
|
412
|
+
);
|
|
289
413
|
}
|
|
290
414
|
switch (typeof type) {
|
|
291
|
-
case
|
|
415
|
+
case "string":
|
|
292
416
|
return renderNativeComponent(type, props, context, legacyContext);
|
|
293
|
-
case
|
|
294
|
-
if (type.prototype && typeof type.prototype.render ===
|
|
417
|
+
case "function":
|
|
418
|
+
if (type.prototype && typeof type.prototype.render === "function") {
|
|
295
419
|
return renderComponent(type, props, context, legacyContext);
|
|
296
420
|
}
|
|
297
|
-
return renderElement(
|
|
421
|
+
return renderElement(
|
|
422
|
+
type(props, legacyContext),
|
|
423
|
+
context,
|
|
424
|
+
legacyContext
|
|
425
|
+
);
|
|
298
426
|
}
|
|
299
427
|
switch (type && type.$$typeof) {
|
|
300
428
|
case Provider.$$typeof:
|
|
301
429
|
return renderChildren(props.children, props.value, legacyContext);
|
|
302
430
|
case Consumer.$$typeof:
|
|
303
|
-
return renderElement(
|
|
431
|
+
return renderElement(
|
|
432
|
+
props.children(context || type._currentValue),
|
|
433
|
+
context,
|
|
434
|
+
legacyContext
|
|
435
|
+
);
|
|
304
436
|
case ForwardRef.$$typeof:
|
|
305
|
-
return renderElement(
|
|
437
|
+
return renderElement(
|
|
438
|
+
type.render(props),
|
|
439
|
+
context,
|
|
440
|
+
legacyContext
|
|
441
|
+
);
|
|
306
442
|
}
|
|
307
|
-
return
|
|
443
|
+
return "";
|
|
308
444
|
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Serializes a native component type to string.
|
|
312
|
-
* @param type
|
|
313
|
-
* @param props
|
|
314
|
-
* @param context
|
|
315
|
-
* @param legacyContext
|
|
316
|
-
*/
|
|
317
445
|
function renderNativeComponent(type, props, context, legacyContext = {}) {
|
|
318
|
-
let content =
|
|
319
|
-
if (type ===
|
|
320
|
-
// Textarea children can be assigned as value prop. If it is, render in
|
|
321
|
-
// place of children. Ensure to omit so it is not assigned as attribute
|
|
322
|
-
// as well.
|
|
446
|
+
let content = "";
|
|
447
|
+
if (type === "textarea" && props.hasOwnProperty("value")) {
|
|
323
448
|
content = renderChildren(props.value, context, legacyContext);
|
|
324
|
-
const {
|
|
325
|
-
value,
|
|
326
|
-
...restProps
|
|
327
|
-
} = props;
|
|
449
|
+
const { value, ...restProps } = props;
|
|
328
450
|
props = restProps;
|
|
329
|
-
} else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html ===
|
|
330
|
-
// Dangerous content is left unescaped.
|
|
451
|
+
} else if (props.dangerouslySetInnerHTML && typeof props.dangerouslySetInnerHTML.__html === "string") {
|
|
331
452
|
content = props.dangerouslySetInnerHTML.__html;
|
|
332
|
-
} else if (typeof props.children !==
|
|
453
|
+
} else if (typeof props.children !== "undefined") {
|
|
333
454
|
content = renderChildren(props.children, context, legacyContext);
|
|
334
455
|
}
|
|
335
456
|
if (!type) {
|
|
@@ -337,35 +458,20 @@ function renderNativeComponent(type, props, context, legacyContext = {}) {
|
|
|
337
458
|
}
|
|
338
459
|
const attributes = renderAttributes(props);
|
|
339
460
|
if (SELF_CLOSING_TAGS.has(type)) {
|
|
340
|
-
return
|
|
461
|
+
return "<" + type + attributes + "/>";
|
|
341
462
|
}
|
|
342
|
-
return
|
|
463
|
+
return "<" + type + attributes + ">" + content + "</" + type + ">";
|
|
343
464
|
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Serializes a non-native component type to string.
|
|
347
|
-
* @param Component
|
|
348
|
-
* @param props
|
|
349
|
-
* @param context
|
|
350
|
-
* @param legacyContext
|
|
351
|
-
*/
|
|
352
465
|
function renderComponent(Component, props, context, legacyContext = {}) {
|
|
353
466
|
const instance = new Component(props, legacyContext);
|
|
354
|
-
if (typeof instance.getChildContext ===
|
|
467
|
+
if (typeof instance.getChildContext === "function") {
|
|
355
468
|
Object.assign(legacyContext, instance.getChildContext());
|
|
356
469
|
}
|
|
357
470
|
const html = renderElement(instance.render(), context, legacyContext);
|
|
358
471
|
return html;
|
|
359
472
|
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Serializes an array of children to string.
|
|
363
|
-
* @param children
|
|
364
|
-
* @param context
|
|
365
|
-
* @param legacyContext
|
|
366
|
-
*/
|
|
367
473
|
function renderChildren(children, context, legacyContext = {}) {
|
|
368
|
-
let result =
|
|
474
|
+
let result = "";
|
|
369
475
|
const childrenArray = Array.isArray(children) ? children : [children];
|
|
370
476
|
for (let i = 0; i < childrenArray.length; i++) {
|
|
371
477
|
const child = childrenArray[i];
|
|
@@ -373,82 +479,69 @@ function renderChildren(children, context, legacyContext = {}) {
|
|
|
373
479
|
}
|
|
374
480
|
return result;
|
|
375
481
|
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Renders a props object as a string of HTML attributes.
|
|
379
|
-
* @param props
|
|
380
|
-
*/
|
|
381
482
|
function renderAttributes(props) {
|
|
382
|
-
let result =
|
|
483
|
+
let result = "";
|
|
383
484
|
for (const key in props) {
|
|
384
485
|
const attribute = getNormalAttributeName(key);
|
|
385
|
-
if (!(0,
|
|
486
|
+
if (!(0, import_escape_html.isValidAttributeName)(attribute)) {
|
|
386
487
|
continue;
|
|
387
488
|
}
|
|
388
489
|
let value = getNormalAttributeValue(key, props[key]);
|
|
389
|
-
|
|
390
|
-
// If value is not of serializable type, skip.
|
|
391
490
|
if (!ATTRIBUTES_TYPES.has(typeof value)) {
|
|
392
491
|
continue;
|
|
393
492
|
}
|
|
394
|
-
|
|
395
|
-
// Don't render internal attribute names.
|
|
396
493
|
if (isInternalAttribute(key)) {
|
|
397
494
|
continue;
|
|
398
495
|
}
|
|
399
496
|
const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has(attribute);
|
|
400
|
-
|
|
401
|
-
// Boolean attribute should be omitted outright if its value is false.
|
|
402
497
|
if (isBooleanAttribute && value === false) {
|
|
403
498
|
continue;
|
|
404
499
|
}
|
|
405
|
-
const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, [
|
|
406
|
-
|
|
407
|
-
// Only write boolean value as attribute if meaningful.
|
|
408
|
-
if (typeof value === 'boolean' && !isMeaningfulAttribute) {
|
|
500
|
+
const isMeaningfulAttribute = isBooleanAttribute || hasPrefix(key, ["data-", "aria-"]) || ENUMERATED_ATTRIBUTES.has(attribute);
|
|
501
|
+
if (typeof value === "boolean" && !isMeaningfulAttribute) {
|
|
409
502
|
continue;
|
|
410
503
|
}
|
|
411
|
-
result +=
|
|
412
|
-
|
|
413
|
-
// Boolean attributes should write attribute name, but without value.
|
|
414
|
-
// Mere presence of attribute name is effective truthiness.
|
|
504
|
+
result += " " + attribute;
|
|
415
505
|
if (isBooleanAttribute) {
|
|
416
506
|
continue;
|
|
417
507
|
}
|
|
418
|
-
if (typeof value ===
|
|
419
|
-
value = (0,
|
|
508
|
+
if (typeof value === "string") {
|
|
509
|
+
value = (0, import_escape_html.escapeAttribute)(value);
|
|
420
510
|
}
|
|
421
511
|
result += '="' + value + '"';
|
|
422
512
|
}
|
|
423
513
|
return result;
|
|
424
514
|
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* Renders a style object as a string attribute value.
|
|
428
|
-
* @param style
|
|
429
|
-
*/
|
|
430
515
|
function renderStyle(style) {
|
|
431
|
-
|
|
432
|
-
if (!(0, _isPlainObject.isPlainObject)(style)) {
|
|
516
|
+
if (!(0, import_is_plain_object.isPlainObject)(style)) {
|
|
433
517
|
return style;
|
|
434
518
|
}
|
|
435
519
|
let result;
|
|
436
520
|
const styleObj = style;
|
|
437
521
|
for (const property in styleObj) {
|
|
438
522
|
const value = styleObj[property];
|
|
439
|
-
if (null === value ||
|
|
523
|
+
if (null === value || void 0 === value) {
|
|
440
524
|
continue;
|
|
441
525
|
}
|
|
442
526
|
if (result) {
|
|
443
|
-
result +=
|
|
527
|
+
result += ";";
|
|
444
528
|
} else {
|
|
445
|
-
result =
|
|
529
|
+
result = "";
|
|
446
530
|
}
|
|
447
531
|
const normalName = getNormalStylePropertyName(property);
|
|
448
532
|
const normalValue = getNormalStylePropertyValue(property, value);
|
|
449
|
-
result += normalName +
|
|
533
|
+
result += normalName + ":" + normalValue;
|
|
450
534
|
}
|
|
451
535
|
return result;
|
|
452
536
|
}
|
|
453
|
-
var
|
|
454
|
-
|
|
537
|
+
var serialize_default = renderElement;
|
|
538
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
539
|
+
0 && (module.exports = {
|
|
540
|
+
hasPrefix,
|
|
541
|
+
renderAttributes,
|
|
542
|
+
renderComponent,
|
|
543
|
+
renderElement,
|
|
544
|
+
renderNativeComponent,
|
|
545
|
+
renderStyle
|
|
546
|
+
});
|
|
547
|
+
//# sourceMappingURL=serialize.js.map
|