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