@wordpress/element 4.1.0 → 4.1.3-next.a55ed9455a.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/CHANGELOG.md +6 -0
- package/README.md +9 -3
- package/build/create-interpolate-element.js +5 -5
- package/build/create-interpolate-element.js.map +1 -1
- package/build/serialize.js +45 -2
- package/build/serialize.js.map +1 -1
- package/build-module/create-interpolate-element.js +5 -5
- package/build-module/create-interpolate-element.js.map +1 -1
- package/build-module/serialize.js +45 -2
- package/build-module/serialize.js.map +1 -1
- package/build-types/serialize.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/create-interpolate-element.js +5 -5
- package/src/serialize.js +196 -1
- package/src/test/serialize.js +36 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -49,9 +49,9 @@ Refer to the [official React Quick Start guide](https://reactjs.org/docs/hello-w
|
|
|
49
49
|
|
|
50
50
|
## Why React?
|
|
51
51
|
|
|
52
|
-
At the risk of igniting debate surrounding any single "best" front-end framework, the choice to use any tool should be motivated specifically to serve the requirements of the system. In modeling the concept of a [block](/packages/blocks/README.md), we observe the following technical requirements:
|
|
52
|
+
At the risk of igniting debate surrounding any single "best" front-end framework, the choice to use any tool should be motivated specifically to serve the requirements of the system. In modeling the concept of a [block](https://github.com/WordPress/gutenberg/tree/HEAD/packages/blocks/README.md), we observe the following technical requirements:
|
|
53
53
|
|
|
54
|
-
- An understanding of a block in terms of its underlying values (in the [random image example](/packages/blocks/README.md#example), a category)
|
|
54
|
+
- An understanding of a block in terms of its underlying values (in the [random image example](https://github.com/WordPress/gutenberg/tree/HEAD/packages/blocks/README.md#example), a category)
|
|
55
55
|
- A means to describe the UI of a block given these values
|
|
56
56
|
|
|
57
57
|
At its most basic, React provides a simple input / output mechanism. **Given a set of inputs ("props"), a developer describes the output to be shown on the page.** This is most elegantly observed in its [function components](https://reactjs.org/docs/components-and-props.html#functional-and-class-components). React serves the role of reconciling the desired output with the current state of the page.
|
|
@@ -416,4 +416,10 @@ _Related_
|
|
|
416
416
|
|
|
417
417
|
<!-- END TOKEN(Autogenerated API docs) -->
|
|
418
418
|
|
|
419
|
-
|
|
419
|
+
## Contributing to this package
|
|
420
|
+
|
|
421
|
+
This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
|
|
422
|
+
|
|
423
|
+
To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
|
|
424
|
+
|
|
425
|
+
<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
|
|
@@ -188,7 +188,7 @@ function proceed(conversionMap) {
|
|
|
188
188
|
output.push(conversionMap[name]);
|
|
189
189
|
offset = startOffset + tokenLength;
|
|
190
190
|
return true;
|
|
191
|
-
} //
|
|
191
|
+
} // Otherwise we found an inner element.
|
|
192
192
|
|
|
193
193
|
|
|
194
194
|
addChild(createFrame(conversionMap[name], startOffset, tokenLength));
|
|
@@ -201,13 +201,13 @@ function proceed(conversionMap) {
|
|
|
201
201
|
return true;
|
|
202
202
|
|
|
203
203
|
case 'closer':
|
|
204
|
-
//
|
|
204
|
+
// If we're not nesting then this is easy - close the block.
|
|
205
205
|
if (1 === stackDepth) {
|
|
206
206
|
closeOuterElement(startOffset);
|
|
207
207
|
offset = startOffset + tokenLength;
|
|
208
208
|
return true;
|
|
209
|
-
} //
|
|
210
|
-
// block and add it as a innerBlock to the parent
|
|
209
|
+
} // Otherwise we're nested and we have to close out the current
|
|
210
|
+
// block and add it as a innerBlock to the parent.
|
|
211
211
|
|
|
212
212
|
|
|
213
213
|
const stackTop = stack.pop();
|
|
@@ -235,7 +235,7 @@ function proceed(conversionMap) {
|
|
|
235
235
|
|
|
236
236
|
|
|
237
237
|
function nextToken() {
|
|
238
|
-
const matches = tokenizer.exec(indoc); //
|
|
238
|
+
const matches = tokenizer.exec(indoc); // We have no more tokens.
|
|
239
239
|
|
|
240
240
|
if (null === matches) {
|
|
241
241
|
return ['no-more-tokens'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/element/src/create-interpolate-element.js"],"names":["indoc","offset","output","stack","tokenizer","createFrame","element","tokenStart","tokenLength","prevOffset","leadingTextStart","children","createInterpolateElement","interpolatedString","conversionMap","lastIndex","isValidConversionMap","TypeError","proceed","Fragment","isObject","values","Object","length","every","next","nextToken","tokenType","name","startOffset","stackDepth","addText","stackLeadingText","pop","push","substr","addChild","closeOuterElement","stackTop","text","frame","matches","exec","startedAt","index","match","isClosing","isSelfClosed","parent","endOffset"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AAEA,IAAIA,KAAJ,EAAWC,MAAX,EAAmBC,MAAnB,EAA2BC,KAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,SAAS,GAAG,uBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CACCC,OADD,EAECC,UAFD,EAGCC,WAHD,EAICC,UAJD,EAKCC,gBALD,EAME;AACD,SAAO;AACNJ,IAAAA,OADM;AAENC,IAAAA,UAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,UAJM;AAKNC,IAAAA,gBALM;AAMNC,IAAAA,QAAQ,EAAE;AANJ,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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C,CAAtB;AACAqC,EAAAA,MAAM,CAACvC,UAAP,GAAoBA,UAAU,GAAGA,UAAH,GAAgBF,UAAU,GAAGC,WAA3D;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS6B,iBAAT,CAA4BY,SAA5B,EAAwC;AACvC,QAAM;AACL3C,IAAAA,OADK;AAELI,IAAAA,gBAFK;AAGLD,IAAAA,UAHK;AAILF,IAAAA,UAJK;AAKLI,IAAAA;AALK,MAMFR,KAAK,CAAC8B,GAAN,EANJ;AAQA,QAAMM,IAAI,GAAGU,SAAS,GACnBjD,KAAK,CAACmC,MAAN,CAAc1B,UAAd,EAA0BwC,SAAS,GAAGxC,UAAtC,CADmB,GAEnBT,KAAK,CAACmC,MAAN,CAAc1B,UAAd,CAFH;;AAIA,MAAK8B,IAAL,EAAY;AACX5B,IAAAA,QAAQ,CAACuB,IAAT,CAAeK,IAAf;AACA;;AAED,MAAK,SAAS7B,gBAAd,EAAiC;AAChCR,IAAAA,MAAM,CAACgC,IAAP,CACClC,KAAK,CAACmC,MAAN,CAAczB,gBAAd,EAAgCH,UAAU,GAAGG,gBAA7C,CADD;AAGA;;AAEDR,EAAAA,MAAM,CAACgC,IAAP,CAAa,yBAAc5B,OAAd,EAAuB,IAAvB,EAA6B,GAAGK,QAAhC,CAAb;AACA;;eAEcC,wB","sourcesContent":["/**\n * Internal dependencies\n */\nimport { createElement, cloneElement, Fragment, isValidElement } from './react';\n\n/** @typedef {import('./react').WPElement} WPElement */\n\nlet indoc, offset, output, stack;\n\n/**\n * Matches tags in the localized string\n *\n * This is used for extracting the tag pattern groups for parsing the localized\n * string and along with the map converting it to a react element.\n *\n * There are four references extracted using this tokenizer:\n *\n * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)\n * isClosing: The closing slash, it it exists.\n * name: The name portion of the tag (strong, br) (if )\n * isSelfClosed: The slash on a self closing tag, if it exists.\n *\n * @type {RegExp}\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\n/**\n * The stack frame tracking parse progress.\n *\n * @typedef Frame\n *\n * @property {WPElement} element A parent element which may still have\n * @property {number} tokenStart Offset at which parent element first\n * appears.\n * @property {number} tokenLength Length of string marking start of parent\n * element.\n * @property {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @property {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n * @property {WPElement[]} children Children.\n */\n\n/**\n * Tracks recursive-descent parse state.\n *\n * This is a Stack frame holding parent elements until all children have been\n * parsed.\n *\n * @private\n * @param {WPElement} element A parent element which may still have\n * nested children not yet parsed.\n * @param {number} tokenStart Offset at which parent element first\n * appears.\n * @param {number} tokenLength Length of string marking start of parent\n * element.\n * @param {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @param {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return {Frame} The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement,\n\ttokenStart,\n\ttokenLength,\n\tprevOffset,\n\tleadingTextStart\n) {\n\treturn {\n\t\telement,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset,\n\t\tleadingTextStart,\n\t\tchildren: [],\n\t};\n}\n\n/**\n * This function creates an interpolated element from a passed in string with\n * specific tags matching how the string should be converted to an element via\n * the conversion map value.\n *\n * @example\n * For example, for the given string:\n *\n * \"This is a <span>string</span> with <a>a link</a> and a self-closing\n * <CustomComponentB/> tag\"\n *\n * You would have something like this as the conversionMap value:\n *\n * ```js\n * {\n * span: <span />,\n * a: <a href={ 'https://github.com' } />,\n * CustomComponentB: <CustomComponent />,\n * }\n * ```\n *\n * @param {string} interpolatedString The interpolation string to be parsed.\n * @param {Object} conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return {WPElement} A wp element.\n */\nconst createInterpolateElement = ( interpolatedString, conversionMap ) => {\n\tindoc = interpolatedString;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tif ( ! isValidConversionMap( conversionMap ) ) {\n\t\tthrow new TypeError(\n\t\t\t'The conversionMap provided is not valid. It must be an object with values that are WPElements'\n\t\t);\n\t}\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed( conversionMap ) );\n\treturn createElement( Fragment, null, ...output );\n};\n\n/**\n * Validate conversion map.\n *\n * A map is considered valid if it's an object and every value in the object\n * is a WPElement\n *\n * @private\n *\n * @param {Object} conversionMap The map being validated.\n *\n * @return {boolean} True means the map is valid.\n */\nconst isValidConversionMap = ( conversionMap ) => {\n\tconst isObject = typeof conversionMap === 'object';\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param {Object} conversionMap The conversion map for the string.\n *\n * @return {boolean} true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap ) {\n\tconst next = nextToken();\n\tconst [ tokenType, name, startOffset, tokenLength ] = next;\n\tconst stackDepth = stack.length;\n\tconst leadingTextStart = startOffset > offset ? offset : null;\n\tif ( ! conversionMap[ name ] ) {\n\t\taddText();\n\t\treturn false;\n\t}\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\tif ( stackDepth !== 0 ) {\n\t\t\t\tconst {\n\t\t\t\t\tleadingTextStart: stackLeadingText,\n\t\t\t\t\ttokenStart,\n\t\t\t\t} = stack.pop();\n\t\t\t\toutput.push( indoc.substr( stackLeadingText, tokenStart ) );\n\t\t\t}\n\t\t\taddText();\n\t\t\treturn false;\n\n\t\tcase 'self-closed':\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingTextStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tindoc.substr(\n\t\t\t\t\t\t\tleadingTextStart,\n\t\t\t\t\t\t\tstartOffset - leadingTextStart\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( conversionMap[ name ] );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// otherwise we found an inner element\n\t\t\taddChild(\n\t\t\t\tcreateFrame( conversionMap[ name ], startOffset, tokenLength )\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'opener':\n\t\t\tstack.push(\n\t\t\t\tcreateFrame(\n\t\t\t\t\tconversionMap[ name ],\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingTextStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'closer':\n\t\t\t// if we're not nesting then this is easy - close the block\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\tcloseOuterElement( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent\n\t\t\tconst stackTop = stack.pop();\n\t\t\tconst text = indoc.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.children.push( text );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\t\t\tconst frame = createFrame(\n\t\t\t\tstackTop.element,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\tframe.children = stackTop.children;\n\t\t\taddChild( frame );\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\taddText();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Grabs the next token match in the string and returns it's details.\n *\n * @private\n *\n * @return {Array} An array of details for the token matched.\n */\nfunction nextToken() {\n\tconst matches = tokenizer.exec( indoc );\n\t// we have no more tokens\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens' ];\n\t}\n\tconst startedAt = matches.index;\n\tconst [ match, isClosing, name, isSelfClosed ] = matches;\n\tconst length = match.length;\n\tif ( isSelfClosed ) {\n\t\treturn [ 'self-closed', name, startedAt, length ];\n\t}\n\tif ( isClosing ) {\n\t\treturn [ 'closer', name, startedAt, length ];\n\t}\n\treturn [ 'opener', name, startedAt, length ];\n}\n\n/**\n * Pushes text extracted from the indoc string to the output stack given the\n * current rawLength value and offset (if rawLength is provided ) or the\n * indoc.length and offset.\n *\n * @private\n */\nfunction addText() {\n\tconst length = indoc.length - offset;\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\toutput.push( indoc.substr( offset, length ) );\n}\n\n/**\n * Pushes a child element to the associated parent element's children for the\n * parent currently active in the stack.\n *\n * @private\n *\n * @param {Frame} frame The Frame containing the child element and it's\n * token information.\n */\nfunction addChild( frame ) {\n\tconst { element, tokenStart, tokenLength, prevOffset, children } = frame;\n\tconst parent = stack[ stack.length - 1 ];\n\tconst text = indoc.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( text ) {\n\t\tparent.children.push( text );\n\t}\n\n\tparent.children.push( cloneElement( element, null, ...children ) );\n\tparent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;\n}\n\n/**\n * This is called for closing tags. It creates the element currently active in\n * the stack.\n *\n * @private\n *\n * @param {number} endOffset Offset at which the closing tag for the element\n * begins in the string. If this is greater than the\n * prevOffset attached to the element, then this\n * helps capture any remaining nested text nodes in\n * the element.\n */\nfunction closeOuterElement( endOffset ) {\n\tconst {\n\t\telement,\n\t\tleadingTextStart,\n\t\tprevOffset,\n\t\ttokenStart,\n\t\tchildren,\n\t} = stack.pop();\n\n\tconst text = endOffset\n\t\t? indoc.substr( prevOffset, endOffset - prevOffset )\n\t\t: indoc.substr( prevOffset );\n\n\tif ( text ) {\n\t\tchildren.push( text );\n\t}\n\n\tif ( null !== leadingTextStart ) {\n\t\toutput.push(\n\t\t\tindoc.substr( leadingTextStart, tokenStart - leadingTextStart )\n\t\t);\n\t}\n\n\toutput.push( cloneElement( element, null, ...children ) );\n}\n\nexport default createInterpolateElement;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/element/src/create-interpolate-element.js"],"names":["indoc","offset","output","stack","tokenizer","createFrame","element","tokenStart","tokenLength","prevOffset","leadingTextStart","children","createInterpolateElement","interpolatedString","conversionMap","lastIndex","isValidConversionMap","TypeError","proceed","Fragment","isObject","values","Object","length","every","next","nextToken","tokenType","name","startOffset","stackDepth","addText","stackLeadingText","pop","push","substr","addChild","closeOuterElement","stackTop","text","frame","matches","exec","startedAt","index","match","isClosing","isSelfClosed","parent","endOffset"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AAEA,IAAIA,KAAJ,EAAWC,MAAX,EAAmBC,MAAnB,EAA2BC,KAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,SAAS,GAAG,uBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CACCC,OADD,EAECC,UAFD,EAGCC,WAHD,EAICC,UAJD,EAKCC,gBALD,EAME;AACD,SAAO;AACNJ,IAAAA,OADM;AAENC,IAAAA,UAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,UAJM;AAKNC,IAAAA,gBALM;AAMNC,IAAAA,QAAQ,EAAE;AANJ,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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GK,QAAhC,CAAtB;AACAqC,EAAAA,MAAM,CAACvC,UAAP,GAAoBA,UAAU,GAAGA,UAAH,GAAgBF,UAAU,GAAGC,WAA3D;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS6B,iBAAT,CAA4BY,SAA5B,EAAwC;AACvC,QAAM;AACL3C,IAAAA,OADK;AAELI,IAAAA,gBAFK;AAGLD,IAAAA,UAHK;AAILF,IAAAA,UAJK;AAKLI,IAAAA;AALK,MAMFR,KAAK,CAAC8B,GAAN,EANJ;AAQA,QAAMM,IAAI,GAAGU,SAAS,GACnBjD,KAAK,CAACmC,MAAN,CAAc1B,UAAd,EAA0BwC,SAAS,GAAGxC,UAAtC,CADmB,GAEnBT,KAAK,CAACmC,MAAN,CAAc1B,UAAd,CAFH;;AAIA,MAAK8B,IAAL,EAAY;AACX5B,IAAAA,QAAQ,CAACuB,IAAT,CAAeK,IAAf;AACA;;AAED,MAAK,SAAS7B,gBAAd,EAAiC;AAChCR,IAAAA,MAAM,CAACgC,IAAP,CACClC,KAAK,CAACmC,MAAN,CAAczB,gBAAd,EAAgCH,UAAU,GAAGG,gBAA7C,CADD;AAGA;;AAEDR,EAAAA,MAAM,CAACgC,IAAP,CAAa,yBAAc5B,OAAd,EAAuB,IAAvB,EAA6B,GAAGK,QAAhC,CAAb;AACA;;eAEcC,wB","sourcesContent":["/**\n * Internal dependencies\n */\nimport { createElement, cloneElement, Fragment, isValidElement } from './react';\n\n/** @typedef {import('./react').WPElement} WPElement */\n\nlet indoc, offset, output, stack;\n\n/**\n * Matches tags in the localized string\n *\n * This is used for extracting the tag pattern groups for parsing the localized\n * string and along with the map converting it to a react element.\n *\n * There are four references extracted using this tokenizer:\n *\n * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)\n * isClosing: The closing slash, it it exists.\n * name: The name portion of the tag (strong, br) (if )\n * isSelfClosed: The slash on a self closing tag, if it exists.\n *\n * @type {RegExp}\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\n/**\n * The stack frame tracking parse progress.\n *\n * @typedef Frame\n *\n * @property {WPElement} element A parent element which may still have\n * @property {number} tokenStart Offset at which parent element first\n * appears.\n * @property {number} tokenLength Length of string marking start of parent\n * element.\n * @property {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @property {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n * @property {WPElement[]} children Children.\n */\n\n/**\n * Tracks recursive-descent parse state.\n *\n * This is a Stack frame holding parent elements until all children have been\n * parsed.\n *\n * @private\n * @param {WPElement} element A parent element which may still have\n * nested children not yet parsed.\n * @param {number} tokenStart Offset at which parent element first\n * appears.\n * @param {number} tokenLength Length of string marking start of parent\n * element.\n * @param {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @param {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return {Frame} The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement,\n\ttokenStart,\n\ttokenLength,\n\tprevOffset,\n\tleadingTextStart\n) {\n\treturn {\n\t\telement,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset,\n\t\tleadingTextStart,\n\t\tchildren: [],\n\t};\n}\n\n/**\n * This function creates an interpolated element from a passed in string with\n * specific tags matching how the string should be converted to an element via\n * the conversion map value.\n *\n * @example\n * For example, for the given string:\n *\n * \"This is a <span>string</span> with <a>a link</a> and a self-closing\n * <CustomComponentB/> tag\"\n *\n * You would have something like this as the conversionMap value:\n *\n * ```js\n * {\n * span: <span />,\n * a: <a href={ 'https://github.com' } />,\n * CustomComponentB: <CustomComponent />,\n * }\n * ```\n *\n * @param {string} interpolatedString The interpolation string to be parsed.\n * @param {Object} conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return {WPElement} A wp element.\n */\nconst createInterpolateElement = ( interpolatedString, conversionMap ) => {\n\tindoc = interpolatedString;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tif ( ! isValidConversionMap( conversionMap ) ) {\n\t\tthrow new TypeError(\n\t\t\t'The conversionMap provided is not valid. It must be an object with values that are WPElements'\n\t\t);\n\t}\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed( conversionMap ) );\n\treturn createElement( Fragment, null, ...output );\n};\n\n/**\n * Validate conversion map.\n *\n * A map is considered valid if it's an object and every value in the object\n * is a WPElement\n *\n * @private\n *\n * @param {Object} conversionMap The map being validated.\n *\n * @return {boolean} True means the map is valid.\n */\nconst isValidConversionMap = ( conversionMap ) => {\n\tconst isObject = typeof conversionMap === 'object';\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param {Object} conversionMap The conversion map for the string.\n *\n * @return {boolean} true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap ) {\n\tconst next = nextToken();\n\tconst [ tokenType, name, startOffset, tokenLength ] = next;\n\tconst stackDepth = stack.length;\n\tconst leadingTextStart = startOffset > offset ? offset : null;\n\tif ( ! conversionMap[ name ] ) {\n\t\taddText();\n\t\treturn false;\n\t}\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\tif ( stackDepth !== 0 ) {\n\t\t\t\tconst {\n\t\t\t\t\tleadingTextStart: stackLeadingText,\n\t\t\t\t\ttokenStart,\n\t\t\t\t} = stack.pop();\n\t\t\t\toutput.push( indoc.substr( stackLeadingText, tokenStart ) );\n\t\t\t}\n\t\t\taddText();\n\t\t\treturn false;\n\n\t\tcase 'self-closed':\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingTextStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tindoc.substr(\n\t\t\t\t\t\t\tleadingTextStart,\n\t\t\t\t\t\t\tstartOffset - leadingTextStart\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( conversionMap[ name ] );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner element.\n\t\t\taddChild(\n\t\t\t\tcreateFrame( conversionMap[ name ], startOffset, tokenLength )\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'opener':\n\t\t\tstack.push(\n\t\t\t\tcreateFrame(\n\t\t\t\t\tconversionMap[ name ],\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingTextStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'closer':\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\tcloseOuterElement( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = stack.pop();\n\t\t\tconst text = indoc.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.children.push( text );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\t\t\tconst frame = createFrame(\n\t\t\t\tstackTop.element,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\tframe.children = stackTop.children;\n\t\t\taddChild( frame );\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\taddText();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Grabs the next token match in the string and returns it's details.\n *\n * @private\n *\n * @return {Array} An array of details for the token matched.\n */\nfunction nextToken() {\n\tconst matches = tokenizer.exec( indoc );\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens' ];\n\t}\n\tconst startedAt = matches.index;\n\tconst [ match, isClosing, name, isSelfClosed ] = matches;\n\tconst length = match.length;\n\tif ( isSelfClosed ) {\n\t\treturn [ 'self-closed', name, startedAt, length ];\n\t}\n\tif ( isClosing ) {\n\t\treturn [ 'closer', name, startedAt, length ];\n\t}\n\treturn [ 'opener', name, startedAt, length ];\n}\n\n/**\n * Pushes text extracted from the indoc string to the output stack given the\n * current rawLength value and offset (if rawLength is provided ) or the\n * indoc.length and offset.\n *\n * @private\n */\nfunction addText() {\n\tconst length = indoc.length - offset;\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\toutput.push( indoc.substr( offset, length ) );\n}\n\n/**\n * Pushes a child element to the associated parent element's children for the\n * parent currently active in the stack.\n *\n * @private\n *\n * @param {Frame} frame The Frame containing the child element and it's\n * token information.\n */\nfunction addChild( frame ) {\n\tconst { element, tokenStart, tokenLength, prevOffset, children } = frame;\n\tconst parent = stack[ stack.length - 1 ];\n\tconst text = indoc.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( text ) {\n\t\tparent.children.push( text );\n\t}\n\n\tparent.children.push( cloneElement( element, null, ...children ) );\n\tparent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;\n}\n\n/**\n * This is called for closing tags. It creates the element currently active in\n * the stack.\n *\n * @private\n *\n * @param {number} endOffset Offset at which the closing tag for the element\n * begins in the string. If this is greater than the\n * prevOffset attached to the element, then this\n * helps capture any remaining nested text nodes in\n * the element.\n */\nfunction closeOuterElement( endOffset ) {\n\tconst {\n\t\telement,\n\t\tleadingTextStart,\n\t\tprevOffset,\n\t\ttokenStart,\n\t\tchildren,\n\t} = stack.pop();\n\n\tconst text = endOffset\n\t\t? indoc.substr( prevOffset, endOffset - prevOffset )\n\t\t: indoc.substr( prevOffset );\n\n\tif ( text ) {\n\t\tchildren.push( text );\n\t}\n\n\tif ( null !== leadingTextStart ) {\n\t\toutput.push(\n\t\t\tindoc.substr( leadingTextStart, tokenStart - leadingTextStart )\n\t\t);\n\t}\n\n\toutput.push( cloneElement( element, null, ...children ) );\n}\n\nexport default createInterpolateElement;\n"]}
|
package/build/serialize.js
CHANGED
|
@@ -185,6 +185,40 @@ function getNormalAttributeValue(attribute, value) {
|
|
|
185
185
|
|
|
186
186
|
return value;
|
|
187
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).
|
|
190
|
+
* We need this to render e.g strokeWidth as stroke-width.
|
|
191
|
+
*
|
|
192
|
+
* List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
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) => {
|
|
197
|
+
// The keys are lower-cased for more robust lookup.
|
|
198
|
+
map[attribute.toLowerCase()] = attribute;
|
|
199
|
+
return map;
|
|
200
|
+
}, {});
|
|
201
|
+
/**
|
|
202
|
+
* This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).
|
|
203
|
+
* The keys are lower-cased for more robust lookup.
|
|
204
|
+
* Note that this list only contains attributes that contain at least one capital letter.
|
|
205
|
+
* Lowercase attributes don't need mapping, since we lowercase all attributes by default.
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
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) => {
|
|
209
|
+
// The keys are lower-cased for more robust lookup.
|
|
210
|
+
map[attribute.toLowerCase()] = attribute;
|
|
211
|
+
return map;
|
|
212
|
+
}, {});
|
|
213
|
+
/**
|
|
214
|
+
* This is a map of all SVG attributes that have colons.
|
|
215
|
+
* Keys are lower-cased and stripped of their colons for more robust lookup.
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
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) => {
|
|
219
|
+
map[attribute.replace(':', '').toLowerCase()] = attribute;
|
|
220
|
+
return map;
|
|
221
|
+
}, {});
|
|
188
222
|
/**
|
|
189
223
|
* Returns the normal form of the element's attribute name for HTML.
|
|
190
224
|
*
|
|
@@ -193,7 +227,6 @@ function getNormalAttributeValue(attribute, value) {
|
|
|
193
227
|
* @return {string} Normalized attribute name.
|
|
194
228
|
*/
|
|
195
229
|
|
|
196
|
-
|
|
197
230
|
function getNormalAttributeName(attribute) {
|
|
198
231
|
switch (attribute) {
|
|
199
232
|
case 'htmlFor':
|
|
@@ -203,7 +236,17 @@ function getNormalAttributeName(attribute) {
|
|
|
203
236
|
return 'class';
|
|
204
237
|
}
|
|
205
238
|
|
|
206
|
-
|
|
239
|
+
const attributeLowerCase = attribute.toLowerCase();
|
|
240
|
+
|
|
241
|
+
if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
|
|
242
|
+
return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
|
|
243
|
+
} else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
|
|
244
|
+
return (0, _lodash.kebabCase)(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]);
|
|
245
|
+
} else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
|
|
246
|
+
return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return attributeLowerCase;
|
|
207
250
|
}
|
|
208
251
|
/**
|
|
209
252
|
* Returns the normal form of the style property name for HTML.
|
package/build/serialize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/element/src/serialize.js"],"names":["Provider","Consumer","undefined","ForwardRef","ATTRIBUTES_TYPES","Set","SELF_CLOSING_TAGS","BOOLEAN_ATTRIBUTES","ENUMERATED_ATTRIBUTES","CSS_PROPERTIES_SUPPORTS_UNITLESS","hasPrefix","string","prefixes","some","prefix","indexOf","isInternalAttribute","attribute","getNormalAttributeValue","value","renderStyle","getNormalAttributeName","toLowerCase","getNormalStylePropertyName","property","getNormalStylePropertyValue","has","renderElement","element","context","legacyContext","Array","isArray","renderChildren","toString","type","props","StrictMode","Fragment","children","RawHTML","wrapperProps","renderNativeComponent","dangerouslySetInnerHTML","__html","prototype","render","renderComponent","$$typeof","_currentValue","content","hasOwnProperty","attributes","renderAttributes","Component","instance","getChildContext","Object","assign","html","result","i","length","child","key","isBooleanAttribute","isMeaningfulAttribute","style","normalName","normalValue"],"mappings":";;;;;;;;;;;;;;;AA8BA;;AAYA;;AASA;;AACA;;AApDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAUA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AAEA,MAAM;AAAEA,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,IAAyB,0BAAeC,SAAf,CAA/B;AACA,MAAMC,UAAU,GAAG,uBAAY,MAAM;AACpC,SAAO,IAAP;AACA,CAFkB,CAAnB;AAIA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,IAAIC,GAAJ,CAAS,CAAE,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E,KAAP,KAAiB,SAAjB,IAA8B,CAAE+C,qBAArC,EAA6D;AAC5D;AACA;;AAEDN,IAAAA,MAAM,IAAI,MAAM3C,SAAhB,CAnC0B,CAqC1B;AACA;;AACA,QAAKgD,kBAAL,EAA0B;AACzB;AACA;;AAED,QAAK,OAAO9C,KAAP,KAAiB,QAAtB,EAAiC;AAChCA,MAAAA,KAAK,GAAG,iCAAiBA,KAAjB,CAAR;AACA;;AAEDyC,IAAAA,MAAM,IAAI,OAAOzC,KAAP,GAAe,GAAzB;AACA;;AAED,SAAOyC,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASxC,WAAT,CAAsB+C,KAAtB,EAA8B;AACpC;AACA,MAAK,CAAE,2BAAeA,KAAf,CAAP,EAAgC;AAC/B,WAAOA,KAAP;AACA;;AAED,MAAIP,MAAJ;;AAEA,OAAM,MAAMpC,QAAZ,IAAwB2C,KAAxB,EAAgC;AAC/B,UAAMhD,KAAK,GAAGgD,KAAK,CAAE3C,QAAF,CAAnB;;AACA,QAAK,SAASL,KAAT,IAAkBjB,SAAS,KAAKiB,KAArC,EAA6C;AAC5C;AACA;;AAED,QAAKyC,MAAL,EAAc;AACbA,MAAAA,MAAM,IAAI,GAAV;AACA,KAFD,MAEO;AACNA,MAAAA,MAAM,GAAG,EAAT;AACA;;AAED,UAAMQ,UAAU,GAAG7C,0BAA0B,CAAEC,QAAF,CAA7C;AACA,UAAM6C,WAAW,GAAG5C,2BAA2B,CAAED,QAAF,EAAYL,KAAZ,CAA/C;AACAyC,IAAAA,MAAM,IAAIQ,UAAU,GAAG,GAAb,GAAmBC,WAA7B;AACA;;AAED,SAAOT,MAAP;AACA;;eAEcjC,a","sourcesContent":["/**\n * Parts of this source were derived and modified from fast-react-render,\n * released under the MIT license.\n *\n * https://github.com/alt-j/fast-react-render\n *\n * Copyright (c) 2016 Andrey Morozov\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * External dependencies\n */\nimport {\n\tisEmpty,\n\tcastArray,\n\tomit,\n\tstartsWith,\n\tkebabCase,\n\tisPlainObject,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tescapeHTML,\n\tescapeAttribute,\n\tisValidAttributeName,\n} from '@wordpress/escape-html';\n\n/**\n * Internal dependencies\n */\nimport { createContext, Fragment, StrictMode, forwardRef } from './react';\nimport RawHTML from './raw-html';\n\n/** @typedef {import('./react').WPElement} WPElement */\n\nconst { Provider, Consumer } = createContext( undefined );\nconst ForwardRef = forwardRef( () => {\n\treturn null;\n} );\n\n/**\n * Valid attribute types.\n *\n * @type {Set<string>}\n */\nconst ATTRIBUTES_TYPES = new Set( [ 'string', 'boolean', 'number' ] );\n\n/**\n * Element tags which can be self-closing.\n *\n * @type {Set<string>}\n */\nconst SELF_CLOSING_TAGS = new Set( [\n\t'area',\n\t'base',\n\t'br',\n\t'col',\n\t'command',\n\t'embed',\n\t'hr',\n\t'img',\n\t'input',\n\t'keygen',\n\t'link',\n\t'meta',\n\t'param',\n\t'source',\n\t'track',\n\t'wbr',\n] );\n\n/**\n * Boolean attributes are attributes whose presence as being assigned is\n * meaningful, even if only empty.\n *\n * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes\n * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n *\n * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]\n * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )\n * .reduce( ( result, tr ) => Object.assign( result, {\n * [ tr.firstChild.textContent.trim() ]: true\n * } ), {} ) ).sort();\n *\n * @type {Set<string>}\n */\nconst BOOLEAN_ATTRIBUTES = new Set( [\n\t'allowfullscreen',\n\t'allowpaymentrequest',\n\t'allowusermedia',\n\t'async',\n\t'autofocus',\n\t'autoplay',\n\t'checked',\n\t'controls',\n\t'default',\n\t'defer',\n\t'disabled',\n\t'download',\n\t'formnovalidate',\n\t'hidden',\n\t'ismap',\n\t'itemscope',\n\t'loop',\n\t'multiple',\n\t'muted',\n\t'nomodule',\n\t'novalidate',\n\t'open',\n\t'playsinline',\n\t'readonly',\n\t'required',\n\t'reversed',\n\t'selected',\n\t'typemustmatch',\n] );\n\n/**\n * Enumerated attributes are attributes which must be of a specific value form.\n * Like boolean attributes, these are meaningful if specified, even if not of a\n * valid enumerated value.\n *\n * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute\n * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n *\n * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]\n * .filter( ( tr ) => /^(\"(.+?)\";?\\s*)+/.test( tr.lastChild.textContent.trim() ) )\n * .reduce( ( result, tr ) => Object.assign( result, {\n * [ tr.firstChild.textContent.trim() ]: true\n * } ), {} ) ).sort();\n *\n * Some notable omissions:\n *\n * - `alt`: https://blog.whatwg.org/omit-alt\n *\n * @type {Set<string>}\n */\nconst ENUMERATED_ATTRIBUTES = new Set( [\n\t'autocapitalize',\n\t'autocomplete',\n\t'charset',\n\t'contenteditable',\n\t'crossorigin',\n\t'decoding',\n\t'dir',\n\t'draggable',\n\t'enctype',\n\t'formenctype',\n\t'formmethod',\n\t'http-equiv',\n\t'inputmode',\n\t'kind',\n\t'method',\n\t'preload',\n\t'scope',\n\t'shape',\n\t'spellcheck',\n\t'translate',\n\t'type',\n\t'wrap',\n] );\n\n/**\n * Set of CSS style properties which support assignment of unitless numbers.\n * Used in rendering of style properties, where `px` unit is assumed unless\n * property is included in this set or value is zero.\n *\n * Generated via:\n *\n * Object.entries( document.createElement( 'div' ).style )\n * .filter( ( [ key ] ) => (\n * ! /^(webkit|ms|moz)/.test( key ) &&\n * ( e.style[ key ] = 10 ) &&\n * e.style[ key ] === '10'\n * ) )\n * .map( ( [ key ] ) => key )\n * .sort();\n *\n * @type {Set<string>}\n */\nconst CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set( [\n\t'animation',\n\t'animationIterationCount',\n\t'baselineShift',\n\t'borderImageOutset',\n\t'borderImageSlice',\n\t'borderImageWidth',\n\t'columnCount',\n\t'cx',\n\t'cy',\n\t'fillOpacity',\n\t'flexGrow',\n\t'flexShrink',\n\t'floodOpacity',\n\t'fontWeight',\n\t'gridColumnEnd',\n\t'gridColumnStart',\n\t'gridRowEnd',\n\t'gridRowStart',\n\t'lineHeight',\n\t'opacity',\n\t'order',\n\t'orphans',\n\t'r',\n\t'rx',\n\t'ry',\n\t'shapeImageThreshold',\n\t'stopOpacity',\n\t'strokeDasharray',\n\t'strokeDashoffset',\n\t'strokeMiterlimit',\n\t'strokeOpacity',\n\t'strokeWidth',\n\t'tabSize',\n\t'widows',\n\t'x',\n\t'y',\n\t'zIndex',\n\t'zoom',\n] );\n\n/**\n * Returns true if the specified string is prefixed by one of an array of\n * possible prefixes.\n *\n * @param {string} string String to check.\n * @param {string[]} prefixes Possible prefixes.\n *\n * @return {boolean} Whether string has prefix.\n */\nexport function hasPrefix( string, prefixes ) {\n\treturn prefixes.some( ( prefix ) => string.indexOf( prefix ) === 0 );\n}\n\n/**\n * Returns true if the given prop name should be ignored in attributes\n * serialization, or false otherwise.\n *\n * @param {string} attribute Attribute to check.\n *\n * @return {boolean} Whether attribute should be ignored.\n */\nfunction isInternalAttribute( attribute ) {\n\treturn 'key' === attribute || 'children' === attribute;\n}\n\n/**\n * Returns the normal form of the element's attribute value for HTML.\n *\n * @param {string} attribute Attribute name.\n * @param {*} value Non-normalized attribute value.\n *\n * @return {*} Normalized attribute value.\n */\nfunction getNormalAttributeValue( attribute, value ) {\n\tswitch ( attribute ) {\n\t\tcase 'style':\n\t\t\treturn renderStyle( value );\n\t}\n\n\treturn value;\n}\n\n/**\n * Returns the normal form of the element's attribute name for HTML.\n *\n * @param {string} attribute Non-normalized attribute name.\n *\n * @return {string} Normalized attribute name.\n */\nfunction getNormalAttributeName( attribute ) {\n\tswitch ( attribute ) {\n\t\tcase 'htmlFor':\n\t\t\treturn 'for';\n\n\t\tcase 'className':\n\t\t\treturn 'class';\n\t}\n\n\treturn attribute.toLowerCase();\n}\n\n/**\n * Returns the normal form of the style property name for HTML.\n *\n * - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'\n * - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'\n * - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'\n *\n * @param {string} property Property name.\n *\n * @return {string} Normalized property name.\n */\nfunction getNormalStylePropertyName( property ) {\n\tif ( startsWith( property, '--' ) ) {\n\t\treturn property;\n\t}\n\n\tif ( hasPrefix( property, [ 'ms', 'O', 'Moz', 'Webkit' ] ) ) {\n\t\treturn '-' + kebabCase( property );\n\t}\n\n\treturn kebabCase( property );\n}\n\n/**\n * Returns the normal form of the style property value for HTML. Appends a\n * default pixel unit if numeric, not a unitless property, and not zero.\n *\n * @param {string} property Property name.\n * @param {*} value Non-normalized property value.\n *\n * @return {*} Normalized property value.\n */\nfunction getNormalStylePropertyValue( property, value ) {\n\tif (\n\t\ttypeof value === 'number' &&\n\t\t0 !== value &&\n\t\t! CSS_PROPERTIES_SUPPORTS_UNITLESS.has( property )\n\t) {\n\t\treturn value + 'px';\n\t}\n\n\treturn value;\n}\n\n/**\n * Serializes a React element to string.\n *\n * @param {import('react').ReactNode} element Element to serialize.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element.\n */\nexport function renderElement( element, context, legacyContext = {} ) {\n\tif ( null === element || undefined === element || false === element ) {\n\t\treturn '';\n\t}\n\n\tif ( Array.isArray( element ) ) {\n\t\treturn renderChildren( element, context, legacyContext );\n\t}\n\n\tswitch ( typeof element ) {\n\t\tcase 'string':\n\t\t\treturn escapeHTML( element );\n\n\t\tcase 'number':\n\t\t\treturn element.toString();\n\t}\n\n\tconst {\n\t\ttype,\n\t\tprops,\n\t} = /** @type {{type?: any, props?: any}} */ ( element );\n\n\tswitch ( type ) {\n\t\tcase StrictMode:\n\t\tcase Fragment:\n\t\t\treturn renderChildren( props.children, context, legacyContext );\n\n\t\tcase RawHTML:\n\t\t\tconst { children, ...wrapperProps } = props;\n\n\t\t\treturn renderNativeComponent(\n\t\t\t\tisEmpty( wrapperProps ) ? null : 'div',\n\t\t\t\t{\n\t\t\t\t\t...wrapperProps,\n\t\t\t\t\tdangerouslySetInnerHTML: { __html: children },\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\tswitch ( typeof type ) {\n\t\tcase 'string':\n\t\t\treturn renderNativeComponent( type, props, context, legacyContext );\n\n\t\tcase 'function':\n\t\t\tif (\n\t\t\t\ttype.prototype &&\n\t\t\t\ttypeof type.prototype.render === 'function'\n\t\t\t) {\n\t\t\t\treturn renderComponent( type, props, context, legacyContext );\n\t\t\t}\n\n\t\t\treturn renderElement(\n\t\t\t\ttype( props, legacyContext ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\tswitch ( type && type.$$typeof ) {\n\t\tcase Provider.$$typeof:\n\t\t\treturn renderChildren( props.children, props.value, legacyContext );\n\n\t\tcase Consumer.$$typeof:\n\t\t\treturn renderElement(\n\t\t\t\tprops.children( context || type._currentValue ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\n\t\tcase ForwardRef.$$typeof:\n\t\t\treturn renderElement(\n\t\t\t\ttype.render( props ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\treturn '';\n}\n\n/**\n * Serializes a native component type to string.\n *\n * @param {?string} type Native component type to serialize, or null if\n * rendering as fragment of children content.\n * @param {Object} props Props object.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element.\n */\nexport function renderNativeComponent(\n\ttype,\n\tprops,\n\tcontext,\n\tlegacyContext = {}\n) {\n\tlet content = '';\n\tif ( type === 'textarea' && props.hasOwnProperty( 'value' ) ) {\n\t\t// Textarea children can be assigned as value prop. If it is, render in\n\t\t// place of children. Ensure to omit so it is not assigned as attribute\n\t\t// as well.\n\t\tcontent = renderChildren( props.value, context, legacyContext );\n\t\tprops = omit( props, 'value' );\n\t} else if (\n\t\tprops.dangerouslySetInnerHTML &&\n\t\ttypeof props.dangerouslySetInnerHTML.__html === 'string'\n\t) {\n\t\t// Dangerous content is left unescaped.\n\t\tcontent = props.dangerouslySetInnerHTML.__html;\n\t} else if ( typeof props.children !== 'undefined' ) {\n\t\tcontent = renderChildren( props.children, context, legacyContext );\n\t}\n\n\tif ( ! type ) {\n\t\treturn content;\n\t}\n\n\tconst attributes = renderAttributes( props );\n\n\tif ( SELF_CLOSING_TAGS.has( type ) ) {\n\t\treturn '<' + type + attributes + '/>';\n\t}\n\n\treturn '<' + type + attributes + '>' + content + '</' + type + '>';\n}\n\n/** @typedef {import('./react').WPComponent} WPComponent */\n\n/**\n * Serializes a non-native component type to string.\n *\n * @param {WPComponent} Component Component type to serialize.\n * @param {Object} props Props object.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element\n */\nexport function renderComponent(\n\tComponent,\n\tprops,\n\tcontext,\n\tlegacyContext = {}\n) {\n\tconst instance = new /** @type {import('react').ComponentClass} */ ( Component )(\n\t\tprops,\n\t\tlegacyContext\n\t);\n\n\tif (\n\t\ttypeof (\n\t\t\t// Ignore reason: Current prettier reformats parens and mangles type assertion\n\t\t\t// prettier-ignore\n\t\t\t/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext\n\t\t) === 'function'\n\t) {\n\t\tObject.assign(\n\t\t\tlegacyContext,\n\t\t\t/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext()\n\t\t);\n\t}\n\n\tconst html = renderElement( instance.render(), context, legacyContext );\n\n\treturn html;\n}\n\n/**\n * Serializes an array of children to string.\n *\n * @param {import('react').ReactNodeArray} children Children to serialize.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized children.\n */\nfunction renderChildren( children, context, legacyContext = {} ) {\n\tlet result = '';\n\n\tchildren = castArray( children );\n\n\tfor ( let i = 0; i < children.length; i++ ) {\n\t\tconst child = children[ i ];\n\n\t\tresult += renderElement( child, context, legacyContext );\n\t}\n\n\treturn result;\n}\n\n/**\n * Renders a props object as a string of HTML attributes.\n *\n * @param {Object} props Props object.\n *\n * @return {string} Attributes string.\n */\nexport function renderAttributes( props ) {\n\tlet result = '';\n\n\tfor ( const key in props ) {\n\t\tconst attribute = getNormalAttributeName( key );\n\t\tif ( ! isValidAttributeName( attribute ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet value = getNormalAttributeValue( key, props[ key ] );\n\n\t\t// If value is not of serializeable type, skip.\n\t\tif ( ! ATTRIBUTES_TYPES.has( typeof value ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Don't render internal attribute names.\n\t\tif ( isInternalAttribute( key ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isBooleanAttribute = BOOLEAN_ATTRIBUTES.has( attribute );\n\n\t\t// Boolean attribute should be omitted outright if its value is false.\n\t\tif ( isBooleanAttribute && value === false ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isMeaningfulAttribute =\n\t\t\tisBooleanAttribute ||\n\t\t\thasPrefix( key, [ 'data-', 'aria-' ] ) ||\n\t\t\tENUMERATED_ATTRIBUTES.has( attribute );\n\n\t\t// Only write boolean value as attribute if meaningful.\n\t\tif ( typeof value === 'boolean' && ! isMeaningfulAttribute ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tresult += ' ' + attribute;\n\n\t\t// Boolean attributes should write attribute name, but without value.\n\t\t// Mere presence of attribute name is effective truthiness.\n\t\tif ( isBooleanAttribute ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( typeof value === 'string' ) {\n\t\t\tvalue = escapeAttribute( value );\n\t\t}\n\n\t\tresult += '=\"' + value + '\"';\n\t}\n\n\treturn result;\n}\n\n/**\n * Renders a style object as a string attribute value.\n *\n * @param {Object} style Style object.\n *\n * @return {string} Style attribute value.\n */\nexport function renderStyle( style ) {\n\t// Only generate from object, e.g. tolerate string value.\n\tif ( ! isPlainObject( style ) ) {\n\t\treturn style;\n\t}\n\n\tlet result;\n\n\tfor ( const property in style ) {\n\t\tconst value = style[ property ];\n\t\tif ( null === value || undefined === value ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( result ) {\n\t\t\tresult += ';';\n\t\t} else {\n\t\t\tresult = '';\n\t\t}\n\n\t\tconst normalName = getNormalStylePropertyName( property );\n\t\tconst normalValue = getNormalStylePropertyValue( property, value );\n\t\tresult += normalName + ':' + normalValue;\n\t}\n\n\treturn result;\n}\n\nexport default renderElement;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/element/src/serialize.js"],"names":["Provider","Consumer","undefined","ForwardRef","ATTRIBUTES_TYPES","Set","SELF_CLOSING_TAGS","BOOLEAN_ATTRIBUTES","ENUMERATED_ATTRIBUTES","CSS_PROPERTIES_SUPPORTS_UNITLESS","hasPrefix","string","prefixes","some","prefix","indexOf","isInternalAttribute","attribute","getNormalAttributeValue","value","renderStyle","SVG_ATTRIBUTE_WITH_DASHES_LIST","reduce","map","toLowerCase","CASE_SENSITIVE_SVG_ATTRIBUTES","SVG_ATTRIBUTES_WITH_COLONS","replace","getNormalAttributeName","attributeLowerCase","getNormalStylePropertyName","property","getNormalStylePropertyValue","has","renderElement","element","context","legacyContext","Array","isArray","renderChildren","toString","type","props","StrictMode","Fragment","children","RawHTML","wrapperProps","renderNativeComponent","dangerouslySetInnerHTML","__html","prototype","render","renderComponent","$$typeof","_currentValue","content","hasOwnProperty","attributes","renderAttributes","Component","instance","getChildContext","Object","assign","html","result","i","length","child","key","isBooleanAttribute","isMeaningfulAttribute","style","normalName","normalValue"],"mappings":";;;;;;;;;;;;;;;AA8BA;;AAYA;;AASA;;AACA;;AApDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAUA;AACA;AACA;;AAOA;AACA;AACA;;AAIA;AAEA,MAAM;AAAEA,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,IAAyB,0BAAeC,SAAf,CAA/B;AACA,MAAMC,UAAU,GAAG,uBAAY,MAAM;AACpC,SAAO,IAAP;AACA,CAFkB,CAAnB;AAIA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,IAAIC,GAAJ,CAAS,CAAE,QAAF,EAAY,SAAZ,EAAuB,QAAvB,CAAT,CAAzB;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,iBAAiB,GAAG,IAAID,GAAJ,CAAS,CAClC,MADkC,EAElC,MAFkC,EAGlC,IAHkC,EAIlC,KAJkC,EAKlC,SALkC,EAMlC,OANkC,EAOlC,IA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,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS/C,WAAT,CAAsBsD,KAAtB,EAA8B;AACpC;AACA,MAAK,CAAE,2BAAeA,KAAf,CAAP,EAAgC;AAC/B,WAAOA,KAAP;AACA;;AAED,MAAIP,MAAJ;;AAEA,OAAM,MAAMpC,QAAZ,IAAwB2C,KAAxB,EAAgC;AAC/B,UAAMvD,KAAK,GAAGuD,KAAK,CAAE3C,QAAF,CAAnB;;AACA,QAAK,SAASZ,KAAT,IAAkBjB,SAAS,KAAKiB,KAArC,EAA6C;AAC5C;AACA;;AAED,QAAKgD,MAAL,EAAc;AACbA,MAAAA,MAAM,IAAI,GAAV;AACA,KAFD,MAEO;AACNA,MAAAA,MAAM,GAAG,EAAT;AACA;;AAED,UAAMQ,UAAU,GAAG7C,0BAA0B,CAAEC,QAAF,CAA7C;AACA,UAAM6C,WAAW,GAAG5C,2BAA2B,CAAED,QAAF,EAAYZ,KAAZ,CAA/C;AACAgD,IAAAA,MAAM,IAAIQ,UAAU,GAAG,GAAb,GAAmBC,WAA7B;AACA;;AAED,SAAOT,MAAP;AACA;;eAEcjC,a","sourcesContent":["/**\n * Parts of this source were derived and modified from fast-react-render,\n * released under the MIT license.\n *\n * https://github.com/alt-j/fast-react-render\n *\n * Copyright (c) 2016 Andrey Morozov\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * External dependencies\n */\nimport {\n\tisEmpty,\n\tcastArray,\n\tomit,\n\tstartsWith,\n\tkebabCase,\n\tisPlainObject,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tescapeHTML,\n\tescapeAttribute,\n\tisValidAttributeName,\n} from '@wordpress/escape-html';\n\n/**\n * Internal dependencies\n */\nimport { createContext, Fragment, StrictMode, forwardRef } from './react';\nimport RawHTML from './raw-html';\n\n/** @typedef {import('./react').WPElement} WPElement */\n\nconst { Provider, Consumer } = createContext( undefined );\nconst ForwardRef = forwardRef( () => {\n\treturn null;\n} );\n\n/**\n * Valid attribute types.\n *\n * @type {Set<string>}\n */\nconst ATTRIBUTES_TYPES = new Set( [ 'string', 'boolean', 'number' ] );\n\n/**\n * Element tags which can be self-closing.\n *\n * @type {Set<string>}\n */\nconst SELF_CLOSING_TAGS = new Set( [\n\t'area',\n\t'base',\n\t'br',\n\t'col',\n\t'command',\n\t'embed',\n\t'hr',\n\t'img',\n\t'input',\n\t'keygen',\n\t'link',\n\t'meta',\n\t'param',\n\t'source',\n\t'track',\n\t'wbr',\n] );\n\n/**\n * Boolean attributes are attributes whose presence as being assigned is\n * meaningful, even if only empty.\n *\n * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes\n * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n *\n * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]\n * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )\n * .reduce( ( result, tr ) => Object.assign( result, {\n * [ tr.firstChild.textContent.trim() ]: true\n * } ), {} ) ).sort();\n *\n * @type {Set<string>}\n */\nconst BOOLEAN_ATTRIBUTES = new Set( [\n\t'allowfullscreen',\n\t'allowpaymentrequest',\n\t'allowusermedia',\n\t'async',\n\t'autofocus',\n\t'autoplay',\n\t'checked',\n\t'controls',\n\t'default',\n\t'defer',\n\t'disabled',\n\t'download',\n\t'formnovalidate',\n\t'hidden',\n\t'ismap',\n\t'itemscope',\n\t'loop',\n\t'multiple',\n\t'muted',\n\t'nomodule',\n\t'novalidate',\n\t'open',\n\t'playsinline',\n\t'readonly',\n\t'required',\n\t'reversed',\n\t'selected',\n\t'typemustmatch',\n] );\n\n/**\n * Enumerated attributes are attributes which must be of a specific value form.\n * Like boolean attributes, these are meaningful if specified, even if not of a\n * valid enumerated value.\n *\n * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute\n * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n *\n * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]\n * .filter( ( tr ) => /^(\"(.+?)\";?\\s*)+/.test( tr.lastChild.textContent.trim() ) )\n * .reduce( ( result, tr ) => Object.assign( result, {\n * [ tr.firstChild.textContent.trim() ]: true\n * } ), {} ) ).sort();\n *\n * Some notable omissions:\n *\n * - `alt`: https://blog.whatwg.org/omit-alt\n *\n * @type {Set<string>}\n */\nconst ENUMERATED_ATTRIBUTES = new Set( [\n\t'autocapitalize',\n\t'autocomplete',\n\t'charset',\n\t'contenteditable',\n\t'crossorigin',\n\t'decoding',\n\t'dir',\n\t'draggable',\n\t'enctype',\n\t'formenctype',\n\t'formmethod',\n\t'http-equiv',\n\t'inputmode',\n\t'kind',\n\t'method',\n\t'preload',\n\t'scope',\n\t'shape',\n\t'spellcheck',\n\t'translate',\n\t'type',\n\t'wrap',\n] );\n\n/**\n * Set of CSS style properties which support assignment of unitless numbers.\n * Used in rendering of style properties, where `px` unit is assumed unless\n * property is included in this set or value is zero.\n *\n * Generated via:\n *\n * Object.entries( document.createElement( 'div' ).style )\n * .filter( ( [ key ] ) => (\n * ! /^(webkit|ms|moz)/.test( key ) &&\n * ( e.style[ key ] = 10 ) &&\n * e.style[ key ] === '10'\n * ) )\n * .map( ( [ key ] ) => key )\n * .sort();\n *\n * @type {Set<string>}\n */\nconst CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set( [\n\t'animation',\n\t'animationIterationCount',\n\t'baselineShift',\n\t'borderImageOutset',\n\t'borderImageSlice',\n\t'borderImageWidth',\n\t'columnCount',\n\t'cx',\n\t'cy',\n\t'fillOpacity',\n\t'flexGrow',\n\t'flexShrink',\n\t'floodOpacity',\n\t'fontWeight',\n\t'gridColumnEnd',\n\t'gridColumnStart',\n\t'gridRowEnd',\n\t'gridRowStart',\n\t'lineHeight',\n\t'opacity',\n\t'order',\n\t'orphans',\n\t'r',\n\t'rx',\n\t'ry',\n\t'shapeImageThreshold',\n\t'stopOpacity',\n\t'strokeDasharray',\n\t'strokeDashoffset',\n\t'strokeMiterlimit',\n\t'strokeOpacity',\n\t'strokeWidth',\n\t'tabSize',\n\t'widows',\n\t'x',\n\t'y',\n\t'zIndex',\n\t'zoom',\n] );\n\n/**\n * Returns true if the specified string is prefixed by one of an array of\n * possible prefixes.\n *\n * @param {string} string String to check.\n * @param {string[]} prefixes Possible prefixes.\n *\n * @return {boolean} Whether string has prefix.\n */\nexport function hasPrefix( string, prefixes ) {\n\treturn prefixes.some( ( prefix ) => string.indexOf( prefix ) === 0 );\n}\n\n/**\n * Returns true if the given prop name should be ignored in attributes\n * serialization, or false otherwise.\n *\n * @param {string} attribute Attribute to check.\n *\n * @return {boolean} Whether attribute should be ignored.\n */\nfunction isInternalAttribute( attribute ) {\n\treturn 'key' === attribute || 'children' === attribute;\n}\n\n/**\n * Returns the normal form of the element's attribute value for HTML.\n *\n * @param {string} attribute Attribute name.\n * @param {*} value Non-normalized attribute value.\n *\n * @return {*} Normalized attribute value.\n */\nfunction getNormalAttributeValue( attribute, value ) {\n\tswitch ( attribute ) {\n\t\tcase 'style':\n\t\t\treturn renderStyle( value );\n\t}\n\n\treturn value;\n}\n/**\n * This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).\n * We need this to render e.g strokeWidth as stroke-width.\n *\n * List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.\n */\nconst SVG_ATTRIBUTE_WITH_DASHES_LIST = [\n\t'accentHeight',\n\t'alignmentBaseline',\n\t'arabicForm',\n\t'baselineShift',\n\t'capHeight',\n\t'clipPath',\n\t'clipRule',\n\t'colorInterpolation',\n\t'colorInterpolationFilters',\n\t'colorProfile',\n\t'colorRendering',\n\t'dominantBaseline',\n\t'enableBackground',\n\t'fillOpacity',\n\t'fillRule',\n\t'floodColor',\n\t'floodOpacity',\n\t'fontFamily',\n\t'fontSize',\n\t'fontSizeAdjust',\n\t'fontStretch',\n\t'fontStyle',\n\t'fontVariant',\n\t'fontWeight',\n\t'glyphName',\n\t'glyphOrientationHorizontal',\n\t'glyphOrientationVertical',\n\t'horizAdvX',\n\t'horizOriginX',\n\t'imageRendering',\n\t'letterSpacing',\n\t'lightingColor',\n\t'markerEnd',\n\t'markerMid',\n\t'markerStart',\n\t'overlinePosition',\n\t'overlineThickness',\n\t'paintOrder',\n\t'panose1',\n\t'pointerEvents',\n\t'renderingIntent',\n\t'shapeRendering',\n\t'stopColor',\n\t'stopOpacity',\n\t'strikethroughPosition',\n\t'strikethroughThickness',\n\t'strokeDasharray',\n\t'strokeDashoffset',\n\t'strokeLinecap',\n\t'strokeLinejoin',\n\t'strokeMiterlimit',\n\t'strokeOpacity',\n\t'strokeWidth',\n\t'textAnchor',\n\t'textDecoration',\n\t'textRendering',\n\t'underlinePosition',\n\t'underlineThickness',\n\t'unicodeBidi',\n\t'unicodeRange',\n\t'unitsPerEm',\n\t'vAlphabetic',\n\t'vHanging',\n\t'vIdeographic',\n\t'vMathematical',\n\t'vectorEffect',\n\t'vertAdvY',\n\t'vertOriginX',\n\t'vertOriginY',\n\t'wordSpacing',\n\t'writingMode',\n\t'xmlnsXlink',\n\t'xHeight',\n].reduce( ( map, attribute ) => {\n\t// The keys are lower-cased for more robust lookup.\n\tmap[ attribute.toLowerCase() ] = attribute;\n\treturn map;\n}, {} );\n\n/**\n * This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).\n * The keys are lower-cased for more robust lookup.\n * Note that this list only contains attributes that contain at least one capital letter.\n * Lowercase attributes don't need mapping, since we lowercase all attributes by default.\n */\nconst CASE_SENSITIVE_SVG_ATTRIBUTES = [\n\t'allowReorder',\n\t'attributeName',\n\t'attributeType',\n\t'autoReverse',\n\t'baseFrequency',\n\t'baseProfile',\n\t'calcMode',\n\t'clipPathUnits',\n\t'contentScriptType',\n\t'contentStyleType',\n\t'diffuseConstant',\n\t'edgeMode',\n\t'externalResourcesRequired',\n\t'filterRes',\n\t'filterUnits',\n\t'glyphRef',\n\t'gradientTransform',\n\t'gradientUnits',\n\t'kernelMatrix',\n\t'kernelUnitLength',\n\t'keyPoints',\n\t'keySplines',\n\t'keyTimes',\n\t'lengthAdjust',\n\t'limitingConeAngle',\n\t'markerHeight',\n\t'markerUnits',\n\t'markerWidth',\n\t'maskContentUnits',\n\t'maskUnits',\n\t'numOctaves',\n\t'pathLength',\n\t'patternContentUnits',\n\t'patternTransform',\n\t'patternUnits',\n\t'pointsAtX',\n\t'pointsAtY',\n\t'pointsAtZ',\n\t'preserveAlpha',\n\t'preserveAspectRatio',\n\t'primitiveUnits',\n\t'refX',\n\t'refY',\n\t'repeatCount',\n\t'repeatDur',\n\t'requiredExtensions',\n\t'requiredFeatures',\n\t'specularConstant',\n\t'specularExponent',\n\t'spreadMethod',\n\t'startOffset',\n\t'stdDeviation',\n\t'stitchTiles',\n\t'suppressContentEditableWarning',\n\t'suppressHydrationWarning',\n\t'surfaceScale',\n\t'systemLanguage',\n\t'tableValues',\n\t'targetX',\n\t'targetY',\n\t'textLength',\n\t'viewBox',\n\t'viewTarget',\n\t'xChannelSelector',\n\t'yChannelSelector',\n].reduce( ( map, attribute ) => {\n\t// The keys are lower-cased for more robust lookup.\n\tmap[ attribute.toLowerCase() ] = attribute;\n\treturn map;\n}, {} );\n\n/**\n * This is a map of all SVG attributes that have colons.\n * Keys are lower-cased and stripped of their colons for more robust lookup.\n */\nconst SVG_ATTRIBUTES_WITH_COLONS = [\n\t'xlink:actuate',\n\t'xlink:arcrole',\n\t'xlink:href',\n\t'xlink:role',\n\t'xlink:show',\n\t'xlink:title',\n\t'xlink:type',\n\t'xml:base',\n\t'xml:lang',\n\t'xml:space',\n\t'xmlns:xlink',\n].reduce( ( map, attribute ) => {\n\tmap[ attribute.replace( ':', '' ).toLowerCase() ] = attribute;\n\treturn map;\n}, {} );\n\n/**\n * Returns the normal form of the element's attribute name for HTML.\n *\n * @param {string} attribute Non-normalized attribute name.\n *\n * @return {string} Normalized attribute name.\n */\nfunction getNormalAttributeName( attribute ) {\n\tswitch ( attribute ) {\n\t\tcase 'htmlFor':\n\t\t\treturn 'for';\n\n\t\tcase 'className':\n\t\t\treturn 'class';\n\t}\n\tconst attributeLowerCase = attribute.toLowerCase();\n\n\tif ( CASE_SENSITIVE_SVG_ATTRIBUTES[ attributeLowerCase ] ) {\n\t\treturn CASE_SENSITIVE_SVG_ATTRIBUTES[ attributeLowerCase ];\n\t} else if ( SVG_ATTRIBUTE_WITH_DASHES_LIST[ attributeLowerCase ] ) {\n\t\treturn kebabCase(\n\t\t\tSVG_ATTRIBUTE_WITH_DASHES_LIST[ attributeLowerCase ]\n\t\t);\n\t} else if ( SVG_ATTRIBUTES_WITH_COLONS[ attributeLowerCase ] ) {\n\t\treturn SVG_ATTRIBUTES_WITH_COLONS[ attributeLowerCase ];\n\t}\n\n\treturn attributeLowerCase;\n}\n\n/**\n * Returns the normal form of the style property name for HTML.\n *\n * - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'\n * - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'\n * - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'\n *\n * @param {string} property Property name.\n *\n * @return {string} Normalized property name.\n */\nfunction getNormalStylePropertyName( property ) {\n\tif ( startsWith( property, '--' ) ) {\n\t\treturn property;\n\t}\n\n\tif ( hasPrefix( property, [ 'ms', 'O', 'Moz', 'Webkit' ] ) ) {\n\t\treturn '-' + kebabCase( property );\n\t}\n\n\treturn kebabCase( property );\n}\n\n/**\n * Returns the normal form of the style property value for HTML. Appends a\n * default pixel unit if numeric, not a unitless property, and not zero.\n *\n * @param {string} property Property name.\n * @param {*} value Non-normalized property value.\n *\n * @return {*} Normalized property value.\n */\nfunction getNormalStylePropertyValue( property, value ) {\n\tif (\n\t\ttypeof value === 'number' &&\n\t\t0 !== value &&\n\t\t! CSS_PROPERTIES_SUPPORTS_UNITLESS.has( property )\n\t) {\n\t\treturn value + 'px';\n\t}\n\n\treturn value;\n}\n\n/**\n * Serializes a React element to string.\n *\n * @param {import('react').ReactNode} element Element to serialize.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element.\n */\nexport function renderElement( element, context, legacyContext = {} ) {\n\tif ( null === element || undefined === element || false === element ) {\n\t\treturn '';\n\t}\n\n\tif ( Array.isArray( element ) ) {\n\t\treturn renderChildren( element, context, legacyContext );\n\t}\n\n\tswitch ( typeof element ) {\n\t\tcase 'string':\n\t\t\treturn escapeHTML( element );\n\n\t\tcase 'number':\n\t\t\treturn element.toString();\n\t}\n\n\tconst {\n\t\ttype,\n\t\tprops,\n\t} = /** @type {{type?: any, props?: any}} */ ( element );\n\n\tswitch ( type ) {\n\t\tcase StrictMode:\n\t\tcase Fragment:\n\t\t\treturn renderChildren( props.children, context, legacyContext );\n\n\t\tcase RawHTML:\n\t\t\tconst { children, ...wrapperProps } = props;\n\n\t\t\treturn renderNativeComponent(\n\t\t\t\tisEmpty( wrapperProps ) ? null : 'div',\n\t\t\t\t{\n\t\t\t\t\t...wrapperProps,\n\t\t\t\t\tdangerouslySetInnerHTML: { __html: children },\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\tswitch ( typeof type ) {\n\t\tcase 'string':\n\t\t\treturn renderNativeComponent( type, props, context, legacyContext );\n\n\t\tcase 'function':\n\t\t\tif (\n\t\t\t\ttype.prototype &&\n\t\t\t\ttypeof type.prototype.render === 'function'\n\t\t\t) {\n\t\t\t\treturn renderComponent( type, props, context, legacyContext );\n\t\t\t}\n\n\t\t\treturn renderElement(\n\t\t\t\ttype( props, legacyContext ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\tswitch ( type && type.$$typeof ) {\n\t\tcase Provider.$$typeof:\n\t\t\treturn renderChildren( props.children, props.value, legacyContext );\n\n\t\tcase Consumer.$$typeof:\n\t\t\treturn renderElement(\n\t\t\t\tprops.children( context || type._currentValue ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\n\t\tcase ForwardRef.$$typeof:\n\t\t\treturn renderElement(\n\t\t\t\ttype.render( props ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\treturn '';\n}\n\n/**\n * Serializes a native component type to string.\n *\n * @param {?string} type Native component type to serialize, or null if\n * rendering as fragment of children content.\n * @param {Object} props Props object.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element.\n */\nexport function renderNativeComponent(\n\ttype,\n\tprops,\n\tcontext,\n\tlegacyContext = {}\n) {\n\tlet content = '';\n\tif ( type === 'textarea' && props.hasOwnProperty( 'value' ) ) {\n\t\t// Textarea children can be assigned as value prop. If it is, render in\n\t\t// place of children. Ensure to omit so it is not assigned as attribute\n\t\t// as well.\n\t\tcontent = renderChildren( props.value, context, legacyContext );\n\t\tprops = omit( props, 'value' );\n\t} else if (\n\t\tprops.dangerouslySetInnerHTML &&\n\t\ttypeof props.dangerouslySetInnerHTML.__html === 'string'\n\t) {\n\t\t// Dangerous content is left unescaped.\n\t\tcontent = props.dangerouslySetInnerHTML.__html;\n\t} else if ( typeof props.children !== 'undefined' ) {\n\t\tcontent = renderChildren( props.children, context, legacyContext );\n\t}\n\n\tif ( ! type ) {\n\t\treturn content;\n\t}\n\n\tconst attributes = renderAttributes( props );\n\n\tif ( SELF_CLOSING_TAGS.has( type ) ) {\n\t\treturn '<' + type + attributes + '/>';\n\t}\n\n\treturn '<' + type + attributes + '>' + content + '</' + type + '>';\n}\n\n/** @typedef {import('./react').WPComponent} WPComponent */\n\n/**\n * Serializes a non-native component type to string.\n *\n * @param {WPComponent} Component Component type to serialize.\n * @param {Object} props Props object.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element\n */\nexport function renderComponent(\n\tComponent,\n\tprops,\n\tcontext,\n\tlegacyContext = {}\n) {\n\tconst instance = new /** @type {import('react').ComponentClass} */ ( Component )(\n\t\tprops,\n\t\tlegacyContext\n\t);\n\n\tif (\n\t\ttypeof (\n\t\t\t// Ignore reason: Current prettier reformats parens and mangles type assertion\n\t\t\t// prettier-ignore\n\t\t\t/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext\n\t\t) === 'function'\n\t) {\n\t\tObject.assign(\n\t\t\tlegacyContext,\n\t\t\t/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext()\n\t\t);\n\t}\n\n\tconst html = renderElement( instance.render(), context, legacyContext );\n\n\treturn html;\n}\n\n/**\n * Serializes an array of children to string.\n *\n * @param {import('react').ReactNodeArray} children Children to serialize.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized children.\n */\nfunction renderChildren( children, context, legacyContext = {} ) {\n\tlet result = '';\n\n\tchildren = castArray( children );\n\n\tfor ( let i = 0; i < children.length; i++ ) {\n\t\tconst child = children[ i ];\n\n\t\tresult += renderElement( child, context, legacyContext );\n\t}\n\n\treturn result;\n}\n\n/**\n * Renders a props object as a string of HTML attributes.\n *\n * @param {Object} props Props object.\n *\n * @return {string} Attributes string.\n */\nexport function renderAttributes( props ) {\n\tlet result = '';\n\n\tfor ( const key in props ) {\n\t\tconst attribute = getNormalAttributeName( key );\n\t\tif ( ! isValidAttributeName( attribute ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet value = getNormalAttributeValue( key, props[ key ] );\n\n\t\t// If value is not of serializeable type, skip.\n\t\tif ( ! ATTRIBUTES_TYPES.has( typeof value ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Don't render internal attribute names.\n\t\tif ( isInternalAttribute( key ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isBooleanAttribute = BOOLEAN_ATTRIBUTES.has( attribute );\n\n\t\t// Boolean attribute should be omitted outright if its value is false.\n\t\tif ( isBooleanAttribute && value === false ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isMeaningfulAttribute =\n\t\t\tisBooleanAttribute ||\n\t\t\thasPrefix( key, [ 'data-', 'aria-' ] ) ||\n\t\t\tENUMERATED_ATTRIBUTES.has( attribute );\n\n\t\t// Only write boolean value as attribute if meaningful.\n\t\tif ( typeof value === 'boolean' && ! isMeaningfulAttribute ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tresult += ' ' + attribute;\n\n\t\t// Boolean attributes should write attribute name, but without value.\n\t\t// Mere presence of attribute name is effective truthiness.\n\t\tif ( isBooleanAttribute ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( typeof value === 'string' ) {\n\t\t\tvalue = escapeAttribute( value );\n\t\t}\n\n\t\tresult += '=\"' + value + '\"';\n\t}\n\n\treturn result;\n}\n\n/**\n * Renders a style object as a string attribute value.\n *\n * @param {Object} style Style object.\n *\n * @return {string} Style attribute value.\n */\nexport function renderStyle( style ) {\n\t// Only generate from object, e.g. tolerate string value.\n\tif ( ! isPlainObject( style ) ) {\n\t\treturn style;\n\t}\n\n\tlet result;\n\n\tfor ( const property in style ) {\n\t\tconst value = style[ property ];\n\t\tif ( null === value || undefined === value ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( result ) {\n\t\t\tresult += ';';\n\t\t} else {\n\t\t\tresult = '';\n\t\t}\n\n\t\tconst normalName = getNormalStylePropertyName( property );\n\t\tconst normalValue = getNormalStylePropertyValue( property, value );\n\t\tresult += normalName + ':' + normalValue;\n\t}\n\n\treturn result;\n}\n\nexport default renderElement;\n"]}
|
|
@@ -180,7 +180,7 @@ function proceed(conversionMap) {
|
|
|
180
180
|
output.push(conversionMap[name]);
|
|
181
181
|
offset = startOffset + tokenLength;
|
|
182
182
|
return true;
|
|
183
|
-
} //
|
|
183
|
+
} // Otherwise we found an inner element.
|
|
184
184
|
|
|
185
185
|
|
|
186
186
|
addChild(createFrame(conversionMap[name], startOffset, tokenLength));
|
|
@@ -193,13 +193,13 @@ function proceed(conversionMap) {
|
|
|
193
193
|
return true;
|
|
194
194
|
|
|
195
195
|
case 'closer':
|
|
196
|
-
//
|
|
196
|
+
// If we're not nesting then this is easy - close the block.
|
|
197
197
|
if (1 === stackDepth) {
|
|
198
198
|
closeOuterElement(startOffset);
|
|
199
199
|
offset = startOffset + tokenLength;
|
|
200
200
|
return true;
|
|
201
|
-
} //
|
|
202
|
-
// block and add it as a innerBlock to the parent
|
|
201
|
+
} // Otherwise we're nested and we have to close out the current
|
|
202
|
+
// block and add it as a innerBlock to the parent.
|
|
203
203
|
|
|
204
204
|
|
|
205
205
|
const stackTop = stack.pop();
|
|
@@ -227,7 +227,7 @@ function proceed(conversionMap) {
|
|
|
227
227
|
|
|
228
228
|
|
|
229
229
|
function nextToken() {
|
|
230
|
-
const matches = tokenizer.exec(indoc); //
|
|
230
|
+
const matches = tokenizer.exec(indoc); // We have no more tokens.
|
|
231
231
|
|
|
232
232
|
if (null === matches) {
|
|
233
233
|
return ['no-more-tokens'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/element/src/create-interpolate-element.js"],"names":["createElement","cloneElement","Fragment","isValidElement","indoc","offset","output","stack","tokenizer","createFrame","element","tokenStart","tokenLength","prevOffset","leadingTextStart","children","createInterpolateElement","interpolatedString","conversionMap","lastIndex","isValidConversionMap","TypeError","proceed","isObject","values","Object","length","every","next","nextToken","tokenType","name","startOffset","stackDepth","addText","stackLeadingText","pop","push","substr","addChild","closeOuterElement","stackTop","text","frame","matches","exec","startedAt","index","match","isClosing","isSelfClosed","parent","endOffset"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,YAAxB,EAAsCC,QAAtC,EAAgDC,cAAhD,QAAsE,SAAtE;AAEA;;AAEA,IAAIC,KAAJ,EAAWC,MAAX,EAAmBC,MAAnB,EAA2BC,KAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,SAAS,GAAG,uBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CACCC,OADD,EAECC,UAFD,EAGCC,WAHD,EAICC,UAJD,EAKCC,gBALD,EAME;AACD,SAAO;AACNJ,IAAAA,OADM;AAENC,IAAAA,UAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,UAJM;AAKNC,IAAAA,gBALM;AAMNC,IAAAA,QAAQ,EAAE;AANJ,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMC,wBAAwB,GAAG,CAAEC,kBAAF,EAAsBC,aAAtB,KAAyC;AACz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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS4B,iBAAT,CAA4BY,SAA5B,EAAwC;AACvC,QAAM;AACL1C,IAAAA,OADK;AAELI,IAAAA,gBAFK;AAGLD,IAAAA,UAHK;AAILF,IAAAA,UAJK;AAKLI,IAAAA;AALK,MAMFR,KAAK,CAAC6B,GAAN,EANJ;AAQA,QAAMM,IAAI,GAAGU,SAAS,GACnBhD,KAAK,CAACkC,MAAN,CAAczB,UAAd,EAA0BuC,SAAS,GAAGvC,UAAtC,CADmB,GAEnBT,KAAK,CAACkC,MAAN,CAAczB,UAAd,CAFH;;AAIA,MAAK6B,IAAL,EAAY;AACX3B,IAAAA,QAAQ,CAACsB,IAAT,CAAeK,IAAf;AACA;;AAED,MAAK,SAAS5B,gBAAd,EAAiC;AAChCR,IAAAA,MAAM,CAAC+B,IAAP,CACCjC,KAAK,CAACkC,MAAN,CAAcxB,gBAAd,EAAgCH,UAAU,GAAGG,gBAA7C,CADD;AAGA;;AAEDR,EAAAA,MAAM,CAAC+B,IAAP,CAAapC,YAAY,CAAES,OAAF,EAAW,IAAX,EAAiB,GAAGK,QAApB,CAAzB;AACA;;AAED,eAAeC,wBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport { createElement, cloneElement, Fragment, isValidElement } from './react';\n\n/** @typedef {import('./react').WPElement} WPElement */\n\nlet indoc, offset, output, stack;\n\n/**\n * Matches tags in the localized string\n *\n * This is used for extracting the tag pattern groups for parsing the localized\n * string and along with the map converting it to a react element.\n *\n * There are four references extracted using this tokenizer:\n *\n * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)\n * isClosing: The closing slash, it it exists.\n * name: The name portion of the tag (strong, br) (if )\n * isSelfClosed: The slash on a self closing tag, if it exists.\n *\n * @type {RegExp}\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\n/**\n * The stack frame tracking parse progress.\n *\n * @typedef Frame\n *\n * @property {WPElement} element A parent element which may still have\n * @property {number} tokenStart Offset at which parent element first\n * appears.\n * @property {number} tokenLength Length of string marking start of parent\n * element.\n * @property {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @property {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n * @property {WPElement[]} children Children.\n */\n\n/**\n * Tracks recursive-descent parse state.\n *\n * This is a Stack frame holding parent elements until all children have been\n * parsed.\n *\n * @private\n * @param {WPElement} element A parent element which may still have\n * nested children not yet parsed.\n * @param {number} tokenStart Offset at which parent element first\n * appears.\n * @param {number} tokenLength Length of string marking start of parent\n * element.\n * @param {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @param {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return {Frame} The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement,\n\ttokenStart,\n\ttokenLength,\n\tprevOffset,\n\tleadingTextStart\n) {\n\treturn {\n\t\telement,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset,\n\t\tleadingTextStart,\n\t\tchildren: [],\n\t};\n}\n\n/**\n * This function creates an interpolated element from a passed in string with\n * specific tags matching how the string should be converted to an element via\n * the conversion map value.\n *\n * @example\n * For example, for the given string:\n *\n * \"This is a <span>string</span> with <a>a link</a> and a self-closing\n * <CustomComponentB/> tag\"\n *\n * You would have something like this as the conversionMap value:\n *\n * ```js\n * {\n * span: <span />,\n * a: <a href={ 'https://github.com' } />,\n * CustomComponentB: <CustomComponent />,\n * }\n * ```\n *\n * @param {string} interpolatedString The interpolation string to be parsed.\n * @param {Object} conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return {WPElement} A wp element.\n */\nconst createInterpolateElement = ( interpolatedString, conversionMap ) => {\n\tindoc = interpolatedString;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tif ( ! isValidConversionMap( conversionMap ) ) {\n\t\tthrow new TypeError(\n\t\t\t'The conversionMap provided is not valid. It must be an object with values that are WPElements'\n\t\t);\n\t}\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed( conversionMap ) );\n\treturn createElement( Fragment, null, ...output );\n};\n\n/**\n * Validate conversion map.\n *\n * A map is considered valid if it's an object and every value in the object\n * is a WPElement\n *\n * @private\n *\n * @param {Object} conversionMap The map being validated.\n *\n * @return {boolean} True means the map is valid.\n */\nconst isValidConversionMap = ( conversionMap ) => {\n\tconst isObject = typeof conversionMap === 'object';\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param {Object} conversionMap The conversion map for the string.\n *\n * @return {boolean} true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap ) {\n\tconst next = nextToken();\n\tconst [ tokenType, name, startOffset, tokenLength ] = next;\n\tconst stackDepth = stack.length;\n\tconst leadingTextStart = startOffset > offset ? offset : null;\n\tif ( ! conversionMap[ name ] ) {\n\t\taddText();\n\t\treturn false;\n\t}\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\tif ( stackDepth !== 0 ) {\n\t\t\t\tconst {\n\t\t\t\t\tleadingTextStart: stackLeadingText,\n\t\t\t\t\ttokenStart,\n\t\t\t\t} = stack.pop();\n\t\t\t\toutput.push( indoc.substr( stackLeadingText, tokenStart ) );\n\t\t\t}\n\t\t\taddText();\n\t\t\treturn false;\n\n\t\tcase 'self-closed':\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingTextStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tindoc.substr(\n\t\t\t\t\t\t\tleadingTextStart,\n\t\t\t\t\t\t\tstartOffset - leadingTextStart\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( conversionMap[ name ] );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// otherwise we found an inner element\n\t\t\taddChild(\n\t\t\t\tcreateFrame( conversionMap[ name ], startOffset, tokenLength )\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'opener':\n\t\t\tstack.push(\n\t\t\t\tcreateFrame(\n\t\t\t\t\tconversionMap[ name ],\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingTextStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'closer':\n\t\t\t// if we're not nesting then this is easy - close the block\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\tcloseOuterElement( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent\n\t\t\tconst stackTop = stack.pop();\n\t\t\tconst text = indoc.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.children.push( text );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\t\t\tconst frame = createFrame(\n\t\t\t\tstackTop.element,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\tframe.children = stackTop.children;\n\t\t\taddChild( frame );\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\taddText();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Grabs the next token match in the string and returns it's details.\n *\n * @private\n *\n * @return {Array} An array of details for the token matched.\n */\nfunction nextToken() {\n\tconst matches = tokenizer.exec( indoc );\n\t// we have no more tokens\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens' ];\n\t}\n\tconst startedAt = matches.index;\n\tconst [ match, isClosing, name, isSelfClosed ] = matches;\n\tconst length = match.length;\n\tif ( isSelfClosed ) {\n\t\treturn [ 'self-closed', name, startedAt, length ];\n\t}\n\tif ( isClosing ) {\n\t\treturn [ 'closer', name, startedAt, length ];\n\t}\n\treturn [ 'opener', name, startedAt, length ];\n}\n\n/**\n * Pushes text extracted from the indoc string to the output stack given the\n * current rawLength value and offset (if rawLength is provided ) or the\n * indoc.length and offset.\n *\n * @private\n */\nfunction addText() {\n\tconst length = indoc.length - offset;\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\toutput.push( indoc.substr( offset, length ) );\n}\n\n/**\n * Pushes a child element to the associated parent element's children for the\n * parent currently active in the stack.\n *\n * @private\n *\n * @param {Frame} frame The Frame containing the child element and it's\n * token information.\n */\nfunction addChild( frame ) {\n\tconst { element, tokenStart, tokenLength, prevOffset, children } = frame;\n\tconst parent = stack[ stack.length - 1 ];\n\tconst text = indoc.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( text ) {\n\t\tparent.children.push( text );\n\t}\n\n\tparent.children.push( cloneElement( element, null, ...children ) );\n\tparent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;\n}\n\n/**\n * This is called for closing tags. It creates the element currently active in\n * the stack.\n *\n * @private\n *\n * @param {number} endOffset Offset at which the closing tag for the element\n * begins in the string. If this is greater than the\n * prevOffset attached to the element, then this\n * helps capture any remaining nested text nodes in\n * the element.\n */\nfunction closeOuterElement( endOffset ) {\n\tconst {\n\t\telement,\n\t\tleadingTextStart,\n\t\tprevOffset,\n\t\ttokenStart,\n\t\tchildren,\n\t} = stack.pop();\n\n\tconst text = endOffset\n\t\t? indoc.substr( prevOffset, endOffset - prevOffset )\n\t\t: indoc.substr( prevOffset );\n\n\tif ( text ) {\n\t\tchildren.push( text );\n\t}\n\n\tif ( null !== leadingTextStart ) {\n\t\toutput.push(\n\t\t\tindoc.substr( leadingTextStart, tokenStart - leadingTextStart )\n\t\t);\n\t}\n\n\toutput.push( cloneElement( element, null, ...children ) );\n}\n\nexport default createInterpolateElement;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/element/src/create-interpolate-element.js"],"names":["createElement","cloneElement","Fragment","isValidElement","indoc","offset","output","stack","tokenizer","createFrame","element","tokenStart","tokenLength","prevOffset","leadingTextStart","children","createInterpolateElement","interpolatedString","conversionMap","lastIndex","isValidConversionMap","TypeError","proceed","isObject","values","Object","length","every","next","nextToken","tokenType","name","startOffset","stackDepth","addText","stackLeadingText","pop","push","substr","addChild","closeOuterElement","stackTop","text","frame","matches","exec","startedAt","index","match","isClosing","isSelfClosed","parent","endOffset"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,YAAxB,EAAsCC,QAAtC,EAAgDC,cAAhD,QAAsE,SAAtE;AAEA;;AAEA,IAAIC,KAAJ,EAAWC,MAAX,EAAmBC,MAAnB,EAA2BC,KAA3B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,SAAS,GAAG,uBAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CACCC,OADD,EAECC,UAFD,EAGCC,WAHD,EAICC,UAJD,EAKCC,gBALD,EAME;AACD,SAAO;AACNJ,IAAAA,OADM;AAENC,IAAAA,UAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,UAJM;AAKNC,IAAAA,gBALM;AAMNC,IAAAA,QAAQ,EAAE;AANJ,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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,GAAGK,QAApB,CAAlC;AACAoC,EAAAA,MAAM,CAACtC,UAAP,GAAoBA,UAAU,GAAGA,UAAH,GAAgBF,UAAU,GAAGC,WAA3D;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS4B,iBAAT,CAA4BY,SAA5B,EAAwC;AACvC,QAAM;AACL1C,IAAAA,OADK;AAELI,IAAAA,gBAFK;AAGLD,IAAAA,UAHK;AAILF,IAAAA,UAJK;AAKLI,IAAAA;AALK,MAMFR,KAAK,CAAC6B,GAAN,EANJ;AAQA,QAAMM,IAAI,GAAGU,SAAS,GACnBhD,KAAK,CAACkC,MAAN,CAAczB,UAAd,EAA0BuC,SAAS,GAAGvC,UAAtC,CADmB,GAEnBT,KAAK,CAACkC,MAAN,CAAczB,UAAd,CAFH;;AAIA,MAAK6B,IAAL,EAAY;AACX3B,IAAAA,QAAQ,CAACsB,IAAT,CAAeK,IAAf;AACA;;AAED,MAAK,SAAS5B,gBAAd,EAAiC;AAChCR,IAAAA,MAAM,CAAC+B,IAAP,CACCjC,KAAK,CAACkC,MAAN,CAAcxB,gBAAd,EAAgCH,UAAU,GAAGG,gBAA7C,CADD;AAGA;;AAEDR,EAAAA,MAAM,CAAC+B,IAAP,CAAapC,YAAY,CAAES,OAAF,EAAW,IAAX,EAAiB,GAAGK,QAApB,CAAzB;AACA;;AAED,eAAeC,wBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport { createElement, cloneElement, Fragment, isValidElement } from './react';\n\n/** @typedef {import('./react').WPElement} WPElement */\n\nlet indoc, offset, output, stack;\n\n/**\n * Matches tags in the localized string\n *\n * This is used for extracting the tag pattern groups for parsing the localized\n * string and along with the map converting it to a react element.\n *\n * There are four references extracted using this tokenizer:\n *\n * match: Full match of the tag (i.e. <strong>, </strong>, <br/>)\n * isClosing: The closing slash, it it exists.\n * name: The name portion of the tag (strong, br) (if )\n * isSelfClosed: The slash on a self closing tag, if it exists.\n *\n * @type {RegExp}\n */\nconst tokenizer = /<(\\/)?(\\w+)\\s*(\\/)?>/g;\n\n/**\n * The stack frame tracking parse progress.\n *\n * @typedef Frame\n *\n * @property {WPElement} element A parent element which may still have\n * @property {number} tokenStart Offset at which parent element first\n * appears.\n * @property {number} tokenLength Length of string marking start of parent\n * element.\n * @property {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @property {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n * @property {WPElement[]} children Children.\n */\n\n/**\n * Tracks recursive-descent parse state.\n *\n * This is a Stack frame holding parent elements until all children have been\n * parsed.\n *\n * @private\n * @param {WPElement} element A parent element which may still have\n * nested children not yet parsed.\n * @param {number} tokenStart Offset at which parent element first\n * appears.\n * @param {number} tokenLength Length of string marking start of parent\n * element.\n * @param {number} [prevOffset] Running offset at which parsing should\n * continue.\n * @param {number} [leadingTextStart] Offset at which last closing element\n * finished, used for finding text between\n * elements.\n *\n * @return {Frame} The stack frame tracking parse progress.\n */\nfunction createFrame(\n\telement,\n\ttokenStart,\n\ttokenLength,\n\tprevOffset,\n\tleadingTextStart\n) {\n\treturn {\n\t\telement,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset,\n\t\tleadingTextStart,\n\t\tchildren: [],\n\t};\n}\n\n/**\n * This function creates an interpolated element from a passed in string with\n * specific tags matching how the string should be converted to an element via\n * the conversion map value.\n *\n * @example\n * For example, for the given string:\n *\n * \"This is a <span>string</span> with <a>a link</a> and a self-closing\n * <CustomComponentB/> tag\"\n *\n * You would have something like this as the conversionMap value:\n *\n * ```js\n * {\n * span: <span />,\n * a: <a href={ 'https://github.com' } />,\n * CustomComponentB: <CustomComponent />,\n * }\n * ```\n *\n * @param {string} interpolatedString The interpolation string to be parsed.\n * @param {Object} conversionMap The map used to convert the string to\n * a react element.\n * @throws {TypeError}\n * @return {WPElement} A wp element.\n */\nconst createInterpolateElement = ( interpolatedString, conversionMap ) => {\n\tindoc = interpolatedString;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tif ( ! isValidConversionMap( conversionMap ) ) {\n\t\tthrow new TypeError(\n\t\t\t'The conversionMap provided is not valid. It must be an object with values that are WPElements'\n\t\t);\n\t}\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed( conversionMap ) );\n\treturn createElement( Fragment, null, ...output );\n};\n\n/**\n * Validate conversion map.\n *\n * A map is considered valid if it's an object and every value in the object\n * is a WPElement\n *\n * @private\n *\n * @param {Object} conversionMap The map being validated.\n *\n * @return {boolean} True means the map is valid.\n */\nconst isValidConversionMap = ( conversionMap ) => {\n\tconst isObject = typeof conversionMap === 'object';\n\tconst values = isObject && Object.values( conversionMap );\n\treturn (\n\t\tisObject &&\n\t\tvalues.length &&\n\t\tvalues.every( ( element ) => isValidElement( element ) )\n\t);\n};\n\n/**\n * This is the iterator over the matches in the string.\n *\n * @private\n *\n * @param {Object} conversionMap The conversion map for the string.\n *\n * @return {boolean} true for continuing to iterate, false for finished.\n */\nfunction proceed( conversionMap ) {\n\tconst next = nextToken();\n\tconst [ tokenType, name, startOffset, tokenLength ] = next;\n\tconst stackDepth = stack.length;\n\tconst leadingTextStart = startOffset > offset ? offset : null;\n\tif ( ! conversionMap[ name ] ) {\n\t\taddText();\n\t\treturn false;\n\t}\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\tif ( stackDepth !== 0 ) {\n\t\t\t\tconst {\n\t\t\t\t\tleadingTextStart: stackLeadingText,\n\t\t\t\t\ttokenStart,\n\t\t\t\t} = stack.pop();\n\t\t\t\toutput.push( indoc.substr( stackLeadingText, tokenStart ) );\n\t\t\t}\n\t\t\taddText();\n\t\t\treturn false;\n\n\t\tcase 'self-closed':\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingTextStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tindoc.substr(\n\t\t\t\t\t\t\tleadingTextStart,\n\t\t\t\t\t\t\tstartOffset - leadingTextStart\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( conversionMap[ name ] );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner element.\n\t\t\taddChild(\n\t\t\t\tcreateFrame( conversionMap[ name ], startOffset, tokenLength )\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'opener':\n\t\t\tstack.push(\n\t\t\t\tcreateFrame(\n\t\t\t\t\tconversionMap[ name ],\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingTextStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'closer':\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\tcloseOuterElement( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = stack.pop();\n\t\t\tconst text = indoc.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.children.push( text );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\t\t\tconst frame = createFrame(\n\t\t\t\tstackTop.element,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\tframe.children = stackTop.children;\n\t\t\taddChild( frame );\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\taddText();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Grabs the next token match in the string and returns it's details.\n *\n * @private\n *\n * @return {Array} An array of details for the token matched.\n */\nfunction nextToken() {\n\tconst matches = tokenizer.exec( indoc );\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens' ];\n\t}\n\tconst startedAt = matches.index;\n\tconst [ match, isClosing, name, isSelfClosed ] = matches;\n\tconst length = match.length;\n\tif ( isSelfClosed ) {\n\t\treturn [ 'self-closed', name, startedAt, length ];\n\t}\n\tif ( isClosing ) {\n\t\treturn [ 'closer', name, startedAt, length ];\n\t}\n\treturn [ 'opener', name, startedAt, length ];\n}\n\n/**\n * Pushes text extracted from the indoc string to the output stack given the\n * current rawLength value and offset (if rawLength is provided ) or the\n * indoc.length and offset.\n *\n * @private\n */\nfunction addText() {\n\tconst length = indoc.length - offset;\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\toutput.push( indoc.substr( offset, length ) );\n}\n\n/**\n * Pushes a child element to the associated parent element's children for the\n * parent currently active in the stack.\n *\n * @private\n *\n * @param {Frame} frame The Frame containing the child element and it's\n * token information.\n */\nfunction addChild( frame ) {\n\tconst { element, tokenStart, tokenLength, prevOffset, children } = frame;\n\tconst parent = stack[ stack.length - 1 ];\n\tconst text = indoc.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( text ) {\n\t\tparent.children.push( text );\n\t}\n\n\tparent.children.push( cloneElement( element, null, ...children ) );\n\tparent.prevOffset = prevOffset ? prevOffset : tokenStart + tokenLength;\n}\n\n/**\n * This is called for closing tags. It creates the element currently active in\n * the stack.\n *\n * @private\n *\n * @param {number} endOffset Offset at which the closing tag for the element\n * begins in the string. If this is greater than the\n * prevOffset attached to the element, then this\n * helps capture any remaining nested text nodes in\n * the element.\n */\nfunction closeOuterElement( endOffset ) {\n\tconst {\n\t\telement,\n\t\tleadingTextStart,\n\t\tprevOffset,\n\t\ttokenStart,\n\t\tchildren,\n\t} = stack.pop();\n\n\tconst text = endOffset\n\t\t? indoc.substr( prevOffset, endOffset - prevOffset )\n\t\t: indoc.substr( prevOffset );\n\n\tif ( text ) {\n\t\tchildren.push( text );\n\t}\n\n\tif ( null !== leadingTextStart ) {\n\t\toutput.push(\n\t\t\tindoc.substr( leadingTextStart, tokenStart - leadingTextStart )\n\t\t);\n\t}\n\n\toutput.push( cloneElement( element, null, ...children ) );\n}\n\nexport default createInterpolateElement;\n"]}
|
|
@@ -165,6 +165,40 @@ function getNormalAttributeValue(attribute, value) {
|
|
|
165
165
|
|
|
166
166
|
return value;
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).
|
|
170
|
+
* We need this to render e.g strokeWidth as stroke-width.
|
|
171
|
+
*
|
|
172
|
+
* List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
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) => {
|
|
177
|
+
// The keys are lower-cased for more robust lookup.
|
|
178
|
+
map[attribute.toLowerCase()] = attribute;
|
|
179
|
+
return map;
|
|
180
|
+
}, {});
|
|
181
|
+
/**
|
|
182
|
+
* This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).
|
|
183
|
+
* The keys are lower-cased for more robust lookup.
|
|
184
|
+
* Note that this list only contains attributes that contain at least one capital letter.
|
|
185
|
+
* Lowercase attributes don't need mapping, since we lowercase all attributes by default.
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
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) => {
|
|
189
|
+
// The keys are lower-cased for more robust lookup.
|
|
190
|
+
map[attribute.toLowerCase()] = attribute;
|
|
191
|
+
return map;
|
|
192
|
+
}, {});
|
|
193
|
+
/**
|
|
194
|
+
* This is a map of all SVG attributes that have colons.
|
|
195
|
+
* Keys are lower-cased and stripped of their colons for more robust lookup.
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
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) => {
|
|
199
|
+
map[attribute.replace(':', '').toLowerCase()] = attribute;
|
|
200
|
+
return map;
|
|
201
|
+
}, {});
|
|
168
202
|
/**
|
|
169
203
|
* Returns the normal form of the element's attribute name for HTML.
|
|
170
204
|
*
|
|
@@ -173,7 +207,6 @@ function getNormalAttributeValue(attribute, value) {
|
|
|
173
207
|
* @return {string} Normalized attribute name.
|
|
174
208
|
*/
|
|
175
209
|
|
|
176
|
-
|
|
177
210
|
function getNormalAttributeName(attribute) {
|
|
178
211
|
switch (attribute) {
|
|
179
212
|
case 'htmlFor':
|
|
@@ -183,7 +216,17 @@ function getNormalAttributeName(attribute) {
|
|
|
183
216
|
return 'class';
|
|
184
217
|
}
|
|
185
218
|
|
|
186
|
-
|
|
219
|
+
const attributeLowerCase = attribute.toLowerCase();
|
|
220
|
+
|
|
221
|
+
if (CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase]) {
|
|
222
|
+
return CASE_SENSITIVE_SVG_ATTRIBUTES[attributeLowerCase];
|
|
223
|
+
} else if (SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]) {
|
|
224
|
+
return kebabCase(SVG_ATTRIBUTE_WITH_DASHES_LIST[attributeLowerCase]);
|
|
225
|
+
} else if (SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase]) {
|
|
226
|
+
return SVG_ATTRIBUTES_WITH_COLONS[attributeLowerCase];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return attributeLowerCase;
|
|
187
230
|
}
|
|
188
231
|
/**
|
|
189
232
|
* Returns the normal form of the style property name for HTML.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/element/src/serialize.js"],"names":["isEmpty","castArray","omit","startsWith","kebabCase","isPlainObject","escapeHTML","escapeAttribute","isValidAttributeName","createContext","Fragment","StrictMode","forwardRef","RawHTML","Provider","Consumer","undefined","ForwardRef","ATTRIBUTES_TYPES","Set","SELF_CLOSING_TAGS","BOOLEAN_ATTRIBUTES","ENUMERATED_ATTRIBUTES","CSS_PROPERTIES_SUPPORTS_UNITLESS","hasPrefix","string","prefixes","some","prefix","indexOf","isInternalAttribute","attribute","getNormalAttributeValue","value","renderStyle","getNormalAttributeName","toLowerCase","getNormalStylePropertyName","property","getNormalStylePropertyValue","has","renderElement","element","context","legacyContext","Array","isArray","renderChildren","toString","type","props","children","wrapperProps","renderNativeComponent","dangerouslySetInnerHTML","__html","prototype","render","renderComponent","$$typeof","_currentValue","content","hasOwnProperty","attributes","renderAttributes","Component","instance","getChildContext","Object","assign","html","result","i","length","child","key","isBooleanAttribute","isMeaningfulAttribute","style","normalName","normalValue"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SACCA,OADD,EAECC,SAFD,EAGCC,IAHD,EAICC,UAJD,EAKCC,SALD,EAMCC,aAND,QAOO,QAPP;AASA;AACA;AACA;;AACA,SACCC,UADD,EAECC,eAFD,EAGCC,oBAHD,QAIO,wBAJP;AAMA;AACA;AACA;;AACA,SAASC,aAAT,EAAwBC,QAAxB,EAAkCC,UAAlC,EAA8CC,UAA9C,QAAgE,SAAhE;AACA,OAAOC,OAAP,MAAoB,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G1C,0BAA0B,CAAEC,QAAF,CAA7C;AACA,UAAM0C,WAAW,GAAGzC,2BAA2B,CAAED,QAAF,EAAYL,KAAZ,CAA/C;AACAsC,IAAAA,MAAM,IAAIQ,UAAU,GAAG,GAAb,GAAmBC,WAA7B;AACA;;AAED,SAAOT,MAAP;AACA;AAED,eAAe9B,aAAf","sourcesContent":["/**\n * Parts of this source were derived and modified from fast-react-render,\n * released under the MIT license.\n *\n * https://github.com/alt-j/fast-react-render\n *\n * Copyright (c) 2016 Andrey Morozov\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * External dependencies\n */\nimport {\n\tisEmpty,\n\tcastArray,\n\tomit,\n\tstartsWith,\n\tkebabCase,\n\tisPlainObject,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tescapeHTML,\n\tescapeAttribute,\n\tisValidAttributeName,\n} from '@wordpress/escape-html';\n\n/**\n * Internal dependencies\n */\nimport { createContext, Fragment, StrictMode, forwardRef } from './react';\nimport RawHTML from './raw-html';\n\n/** @typedef {import('./react').WPElement} WPElement */\n\nconst { Provider, Consumer } = createContext( undefined );\nconst ForwardRef = forwardRef( () => {\n\treturn null;\n} );\n\n/**\n * Valid attribute types.\n *\n * @type {Set<string>}\n */\nconst ATTRIBUTES_TYPES = new Set( [ 'string', 'boolean', 'number' ] );\n\n/**\n * Element tags which can be self-closing.\n *\n * @type {Set<string>}\n */\nconst SELF_CLOSING_TAGS = new Set( [\n\t'area',\n\t'base',\n\t'br',\n\t'col',\n\t'command',\n\t'embed',\n\t'hr',\n\t'img',\n\t'input',\n\t'keygen',\n\t'link',\n\t'meta',\n\t'param',\n\t'source',\n\t'track',\n\t'wbr',\n] );\n\n/**\n * Boolean attributes are attributes whose presence as being assigned is\n * meaningful, even if only empty.\n *\n * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes\n * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n *\n * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]\n * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )\n * .reduce( ( result, tr ) => Object.assign( result, {\n * [ tr.firstChild.textContent.trim() ]: true\n * } ), {} ) ).sort();\n *\n * @type {Set<string>}\n */\nconst BOOLEAN_ATTRIBUTES = new Set( [\n\t'allowfullscreen',\n\t'allowpaymentrequest',\n\t'allowusermedia',\n\t'async',\n\t'autofocus',\n\t'autoplay',\n\t'checked',\n\t'controls',\n\t'default',\n\t'defer',\n\t'disabled',\n\t'download',\n\t'formnovalidate',\n\t'hidden',\n\t'ismap',\n\t'itemscope',\n\t'loop',\n\t'multiple',\n\t'muted',\n\t'nomodule',\n\t'novalidate',\n\t'open',\n\t'playsinline',\n\t'readonly',\n\t'required',\n\t'reversed',\n\t'selected',\n\t'typemustmatch',\n] );\n\n/**\n * Enumerated attributes are attributes which must be of a specific value form.\n * Like boolean attributes, these are meaningful if specified, even if not of a\n * valid enumerated value.\n *\n * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute\n * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n *\n * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]\n * .filter( ( tr ) => /^(\"(.+?)\";?\\s*)+/.test( tr.lastChild.textContent.trim() ) )\n * .reduce( ( result, tr ) => Object.assign( result, {\n * [ tr.firstChild.textContent.trim() ]: true\n * } ), {} ) ).sort();\n *\n * Some notable omissions:\n *\n * - `alt`: https://blog.whatwg.org/omit-alt\n *\n * @type {Set<string>}\n */\nconst ENUMERATED_ATTRIBUTES = new Set( [\n\t'autocapitalize',\n\t'autocomplete',\n\t'charset',\n\t'contenteditable',\n\t'crossorigin',\n\t'decoding',\n\t'dir',\n\t'draggable',\n\t'enctype',\n\t'formenctype',\n\t'formmethod',\n\t'http-equiv',\n\t'inputmode',\n\t'kind',\n\t'method',\n\t'preload',\n\t'scope',\n\t'shape',\n\t'spellcheck',\n\t'translate',\n\t'type',\n\t'wrap',\n] );\n\n/**\n * Set of CSS style properties which support assignment of unitless numbers.\n * Used in rendering of style properties, where `px` unit is assumed unless\n * property is included in this set or value is zero.\n *\n * Generated via:\n *\n * Object.entries( document.createElement( 'div' ).style )\n * .filter( ( [ key ] ) => (\n * ! /^(webkit|ms|moz)/.test( key ) &&\n * ( e.style[ key ] = 10 ) &&\n * e.style[ key ] === '10'\n * ) )\n * .map( ( [ key ] ) => key )\n * .sort();\n *\n * @type {Set<string>}\n */\nconst CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set( [\n\t'animation',\n\t'animationIterationCount',\n\t'baselineShift',\n\t'borderImageOutset',\n\t'borderImageSlice',\n\t'borderImageWidth',\n\t'columnCount',\n\t'cx',\n\t'cy',\n\t'fillOpacity',\n\t'flexGrow',\n\t'flexShrink',\n\t'floodOpacity',\n\t'fontWeight',\n\t'gridColumnEnd',\n\t'gridColumnStart',\n\t'gridRowEnd',\n\t'gridRowStart',\n\t'lineHeight',\n\t'opacity',\n\t'order',\n\t'orphans',\n\t'r',\n\t'rx',\n\t'ry',\n\t'shapeImageThreshold',\n\t'stopOpacity',\n\t'strokeDasharray',\n\t'strokeDashoffset',\n\t'strokeMiterlimit',\n\t'strokeOpacity',\n\t'strokeWidth',\n\t'tabSize',\n\t'widows',\n\t'x',\n\t'y',\n\t'zIndex',\n\t'zoom',\n] );\n\n/**\n * Returns true if the specified string is prefixed by one of an array of\n * possible prefixes.\n *\n * @param {string} string String to check.\n * @param {string[]} prefixes Possible prefixes.\n *\n * @return {boolean} Whether string has prefix.\n */\nexport function hasPrefix( string, prefixes ) {\n\treturn prefixes.some( ( prefix ) => string.indexOf( prefix ) === 0 );\n}\n\n/**\n * Returns true if the given prop name should be ignored in attributes\n * serialization, or false otherwise.\n *\n * @param {string} attribute Attribute to check.\n *\n * @return {boolean} Whether attribute should be ignored.\n */\nfunction isInternalAttribute( attribute ) {\n\treturn 'key' === attribute || 'children' === attribute;\n}\n\n/**\n * Returns the normal form of the element's attribute value for HTML.\n *\n * @param {string} attribute Attribute name.\n * @param {*} value Non-normalized attribute value.\n *\n * @return {*} Normalized attribute value.\n */\nfunction getNormalAttributeValue( attribute, value ) {\n\tswitch ( attribute ) {\n\t\tcase 'style':\n\t\t\treturn renderStyle( value );\n\t}\n\n\treturn value;\n}\n\n/**\n * Returns the normal form of the element's attribute name for HTML.\n *\n * @param {string} attribute Non-normalized attribute name.\n *\n * @return {string} Normalized attribute name.\n */\nfunction getNormalAttributeName( attribute ) {\n\tswitch ( attribute ) {\n\t\tcase 'htmlFor':\n\t\t\treturn 'for';\n\n\t\tcase 'className':\n\t\t\treturn 'class';\n\t}\n\n\treturn attribute.toLowerCase();\n}\n\n/**\n * Returns the normal form of the style property name for HTML.\n *\n * - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'\n * - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'\n * - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'\n *\n * @param {string} property Property name.\n *\n * @return {string} Normalized property name.\n */\nfunction getNormalStylePropertyName( property ) {\n\tif ( startsWith( property, '--' ) ) {\n\t\treturn property;\n\t}\n\n\tif ( hasPrefix( property, [ 'ms', 'O', 'Moz', 'Webkit' ] ) ) {\n\t\treturn '-' + kebabCase( property );\n\t}\n\n\treturn kebabCase( property );\n}\n\n/**\n * Returns the normal form of the style property value for HTML. Appends a\n * default pixel unit if numeric, not a unitless property, and not zero.\n *\n * @param {string} property Property name.\n * @param {*} value Non-normalized property value.\n *\n * @return {*} Normalized property value.\n */\nfunction getNormalStylePropertyValue( property, value ) {\n\tif (\n\t\ttypeof value === 'number' &&\n\t\t0 !== value &&\n\t\t! CSS_PROPERTIES_SUPPORTS_UNITLESS.has( property )\n\t) {\n\t\treturn value + 'px';\n\t}\n\n\treturn value;\n}\n\n/**\n * Serializes a React element to string.\n *\n * @param {import('react').ReactNode} element Element to serialize.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element.\n */\nexport function renderElement( element, context, legacyContext = {} ) {\n\tif ( null === element || undefined === element || false === element ) {\n\t\treturn '';\n\t}\n\n\tif ( Array.isArray( element ) ) {\n\t\treturn renderChildren( element, context, legacyContext );\n\t}\n\n\tswitch ( typeof element ) {\n\t\tcase 'string':\n\t\t\treturn escapeHTML( element );\n\n\t\tcase 'number':\n\t\t\treturn element.toString();\n\t}\n\n\tconst {\n\t\ttype,\n\t\tprops,\n\t} = /** @type {{type?: any, props?: any}} */ ( element );\n\n\tswitch ( type ) {\n\t\tcase StrictMode:\n\t\tcase Fragment:\n\t\t\treturn renderChildren( props.children, context, legacyContext );\n\n\t\tcase RawHTML:\n\t\t\tconst { children, ...wrapperProps } = props;\n\n\t\t\treturn renderNativeComponent(\n\t\t\t\tisEmpty( wrapperProps ) ? null : 'div',\n\t\t\t\t{\n\t\t\t\t\t...wrapperProps,\n\t\t\t\t\tdangerouslySetInnerHTML: { __html: children },\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\tswitch ( typeof type ) {\n\t\tcase 'string':\n\t\t\treturn renderNativeComponent( type, props, context, legacyContext );\n\n\t\tcase 'function':\n\t\t\tif (\n\t\t\t\ttype.prototype &&\n\t\t\t\ttypeof type.prototype.render === 'function'\n\t\t\t) {\n\t\t\t\treturn renderComponent( type, props, context, legacyContext );\n\t\t\t}\n\n\t\t\treturn renderElement(\n\t\t\t\ttype( props, legacyContext ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\tswitch ( type && type.$$typeof ) {\n\t\tcase Provider.$$typeof:\n\t\t\treturn renderChildren( props.children, props.value, legacyContext );\n\n\t\tcase Consumer.$$typeof:\n\t\t\treturn renderElement(\n\t\t\t\tprops.children( context || type._currentValue ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\n\t\tcase ForwardRef.$$typeof:\n\t\t\treturn renderElement(\n\t\t\t\ttype.render( props ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\treturn '';\n}\n\n/**\n * Serializes a native component type to string.\n *\n * @param {?string} type Native component type to serialize, or null if\n * rendering as fragment of children content.\n * @param {Object} props Props object.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element.\n */\nexport function renderNativeComponent(\n\ttype,\n\tprops,\n\tcontext,\n\tlegacyContext = {}\n) {\n\tlet content = '';\n\tif ( type === 'textarea' && props.hasOwnProperty( 'value' ) ) {\n\t\t// Textarea children can be assigned as value prop. If it is, render in\n\t\t// place of children. Ensure to omit so it is not assigned as attribute\n\t\t// as well.\n\t\tcontent = renderChildren( props.value, context, legacyContext );\n\t\tprops = omit( props, 'value' );\n\t} else if (\n\t\tprops.dangerouslySetInnerHTML &&\n\t\ttypeof props.dangerouslySetInnerHTML.__html === 'string'\n\t) {\n\t\t// Dangerous content is left unescaped.\n\t\tcontent = props.dangerouslySetInnerHTML.__html;\n\t} else if ( typeof props.children !== 'undefined' ) {\n\t\tcontent = renderChildren( props.children, context, legacyContext );\n\t}\n\n\tif ( ! type ) {\n\t\treturn content;\n\t}\n\n\tconst attributes = renderAttributes( props );\n\n\tif ( SELF_CLOSING_TAGS.has( type ) ) {\n\t\treturn '<' + type + attributes + '/>';\n\t}\n\n\treturn '<' + type + attributes + '>' + content + '</' + type + '>';\n}\n\n/** @typedef {import('./react').WPComponent} WPComponent */\n\n/**\n * Serializes a non-native component type to string.\n *\n * @param {WPComponent} Component Component type to serialize.\n * @param {Object} props Props object.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element\n */\nexport function renderComponent(\n\tComponent,\n\tprops,\n\tcontext,\n\tlegacyContext = {}\n) {\n\tconst instance = new /** @type {import('react').ComponentClass} */ ( Component )(\n\t\tprops,\n\t\tlegacyContext\n\t);\n\n\tif (\n\t\ttypeof (\n\t\t\t// Ignore reason: Current prettier reformats parens and mangles type assertion\n\t\t\t// prettier-ignore\n\t\t\t/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext\n\t\t) === 'function'\n\t) {\n\t\tObject.assign(\n\t\t\tlegacyContext,\n\t\t\t/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext()\n\t\t);\n\t}\n\n\tconst html = renderElement( instance.render(), context, legacyContext );\n\n\treturn html;\n}\n\n/**\n * Serializes an array of children to string.\n *\n * @param {import('react').ReactNodeArray} children Children to serialize.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized children.\n */\nfunction renderChildren( children, context, legacyContext = {} ) {\n\tlet result = '';\n\n\tchildren = castArray( children );\n\n\tfor ( let i = 0; i < children.length; i++ ) {\n\t\tconst child = children[ i ];\n\n\t\tresult += renderElement( child, context, legacyContext );\n\t}\n\n\treturn result;\n}\n\n/**\n * Renders a props object as a string of HTML attributes.\n *\n * @param {Object} props Props object.\n *\n * @return {string} Attributes string.\n */\nexport function renderAttributes( props ) {\n\tlet result = '';\n\n\tfor ( const key in props ) {\n\t\tconst attribute = getNormalAttributeName( key );\n\t\tif ( ! isValidAttributeName( attribute ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet value = getNormalAttributeValue( key, props[ key ] );\n\n\t\t// If value is not of serializeable type, skip.\n\t\tif ( ! ATTRIBUTES_TYPES.has( typeof value ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Don't render internal attribute names.\n\t\tif ( isInternalAttribute( key ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isBooleanAttribute = BOOLEAN_ATTRIBUTES.has( attribute );\n\n\t\t// Boolean attribute should be omitted outright if its value is false.\n\t\tif ( isBooleanAttribute && value === false ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isMeaningfulAttribute =\n\t\t\tisBooleanAttribute ||\n\t\t\thasPrefix( key, [ 'data-', 'aria-' ] ) ||\n\t\t\tENUMERATED_ATTRIBUTES.has( attribute );\n\n\t\t// Only write boolean value as attribute if meaningful.\n\t\tif ( typeof value === 'boolean' && ! isMeaningfulAttribute ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tresult += ' ' + attribute;\n\n\t\t// Boolean attributes should write attribute name, but without value.\n\t\t// Mere presence of attribute name is effective truthiness.\n\t\tif ( isBooleanAttribute ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( typeof value === 'string' ) {\n\t\t\tvalue = escapeAttribute( value );\n\t\t}\n\n\t\tresult += '=\"' + value + '\"';\n\t}\n\n\treturn result;\n}\n\n/**\n * Renders a style object as a string attribute value.\n *\n * @param {Object} style Style object.\n *\n * @return {string} Style attribute value.\n */\nexport function renderStyle( style ) {\n\t// Only generate from object, e.g. tolerate string value.\n\tif ( ! isPlainObject( style ) ) {\n\t\treturn style;\n\t}\n\n\tlet result;\n\n\tfor ( const property in style ) {\n\t\tconst value = style[ property ];\n\t\tif ( null === value || undefined === value ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( result ) {\n\t\t\tresult += ';';\n\t\t} else {\n\t\t\tresult = '';\n\t\t}\n\n\t\tconst normalName = getNormalStylePropertyName( property );\n\t\tconst normalValue = getNormalStylePropertyValue( property, value );\n\t\tresult += normalName + ':' + normalValue;\n\t}\n\n\treturn result;\n}\n\nexport default renderElement;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/element/src/serialize.js"],"names":["isEmpty","castArray","omit","startsWith","kebabCase","isPlainObject","escapeHTML","escapeAttribute","isValidAttributeName","createContext","Fragment","StrictMode","forwardRef","RawHTML","Provider","Consumer","undefined","ForwardRef","ATTRIBUTES_TYPES","Set","SELF_CLOSING_TAGS","BOOLEAN_ATTRIBUTES","ENUMERATED_ATTRIBUTES","CSS_PROPERTIES_SUPPORTS_UNITLESS","hasPrefix","string","prefixes","some","prefix","indexOf","isInternalAttribute","attribute","getNormalAttributeValue","value","renderStyle","SVG_ATTRIBUTE_WITH_DASHES_LIST","reduce","map","toLowerCase","CASE_SENSITIVE_SVG_ATTRIBUTES","SVG_ATTRIBUTES_WITH_COLONS","replace","getNormalAttributeName","attributeLowerCase","getNormalStylePropertyName","property","getNormalStylePropertyValue","has","renderElement","element","context","legacyContext","Array","isArray","renderChildren","toString","type","props","children","wrapperProps","renderNativeComponent","dangerouslySetInnerHTML","__html","prototype","render","renderComponent","$$typeof","_currentValue","content","hasOwnProperty","attributes","renderAttributes","Component","instance","getChildContext","Object","assign","html","result","i","length","child","key","isBooleanAttribute","isMeaningfulAttribute","style","normalName","normalValue"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SACCA,OADD,EAECC,SAFD,EAGCC,IAHD,EAICC,UAJD,EAKCC,SALD,E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AI,GAAV;AACA,KAFD,MAEO;AACNA,MAAAA,MAAM,GAAG,EAAT;AACA;;AAED,UAAMQ,UAAU,GAAG1C,0BAA0B,CAAEC,QAAF,CAA7C;AACA,UAAM0C,WAAW,GAAGzC,2BAA2B,CAAED,QAAF,EAAYZ,KAAZ,CAA/C;AACA6C,IAAAA,MAAM,IAAIQ,UAAU,GAAG,GAAb,GAAmBC,WAA7B;AACA;;AAED,SAAOT,MAAP;AACA;AAED,eAAe9B,aAAf","sourcesContent":["/**\n * Parts of this source were derived and modified from fast-react-render,\n * released under the MIT license.\n *\n * https://github.com/alt-j/fast-react-render\n *\n * Copyright (c) 2016 Andrey Morozov\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n\n/**\n * External dependencies\n */\nimport {\n\tisEmpty,\n\tcastArray,\n\tomit,\n\tstartsWith,\n\tkebabCase,\n\tisPlainObject,\n} from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tescapeHTML,\n\tescapeAttribute,\n\tisValidAttributeName,\n} from '@wordpress/escape-html';\n\n/**\n * Internal dependencies\n */\nimport { createContext, Fragment, StrictMode, forwardRef } from './react';\nimport RawHTML from './raw-html';\n\n/** @typedef {import('./react').WPElement} WPElement */\n\nconst { Provider, Consumer } = createContext( undefined );\nconst ForwardRef = forwardRef( () => {\n\treturn null;\n} );\n\n/**\n * Valid attribute types.\n *\n * @type {Set<string>}\n */\nconst ATTRIBUTES_TYPES = new Set( [ 'string', 'boolean', 'number' ] );\n\n/**\n * Element tags which can be self-closing.\n *\n * @type {Set<string>}\n */\nconst SELF_CLOSING_TAGS = new Set( [\n\t'area',\n\t'base',\n\t'br',\n\t'col',\n\t'command',\n\t'embed',\n\t'hr',\n\t'img',\n\t'input',\n\t'keygen',\n\t'link',\n\t'meta',\n\t'param',\n\t'source',\n\t'track',\n\t'wbr',\n] );\n\n/**\n * Boolean attributes are attributes whose presence as being assigned is\n * meaningful, even if only empty.\n *\n * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes\n * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n *\n * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]\n * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )\n * .reduce( ( result, tr ) => Object.assign( result, {\n * [ tr.firstChild.textContent.trim() ]: true\n * } ), {} ) ).sort();\n *\n * @type {Set<string>}\n */\nconst BOOLEAN_ATTRIBUTES = new Set( [\n\t'allowfullscreen',\n\t'allowpaymentrequest',\n\t'allowusermedia',\n\t'async',\n\t'autofocus',\n\t'autoplay',\n\t'checked',\n\t'controls',\n\t'default',\n\t'defer',\n\t'disabled',\n\t'download',\n\t'formnovalidate',\n\t'hidden',\n\t'ismap',\n\t'itemscope',\n\t'loop',\n\t'multiple',\n\t'muted',\n\t'nomodule',\n\t'novalidate',\n\t'open',\n\t'playsinline',\n\t'readonly',\n\t'required',\n\t'reversed',\n\t'selected',\n\t'typemustmatch',\n] );\n\n/**\n * Enumerated attributes are attributes which must be of a specific value form.\n * Like boolean attributes, these are meaningful if specified, even if not of a\n * valid enumerated value.\n *\n * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute\n * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3\n *\n * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]\n * .filter( ( tr ) => /^(\"(.+?)\";?\\s*)+/.test( tr.lastChild.textContent.trim() ) )\n * .reduce( ( result, tr ) => Object.assign( result, {\n * [ tr.firstChild.textContent.trim() ]: true\n * } ), {} ) ).sort();\n *\n * Some notable omissions:\n *\n * - `alt`: https://blog.whatwg.org/omit-alt\n *\n * @type {Set<string>}\n */\nconst ENUMERATED_ATTRIBUTES = new Set( [\n\t'autocapitalize',\n\t'autocomplete',\n\t'charset',\n\t'contenteditable',\n\t'crossorigin',\n\t'decoding',\n\t'dir',\n\t'draggable',\n\t'enctype',\n\t'formenctype',\n\t'formmethod',\n\t'http-equiv',\n\t'inputmode',\n\t'kind',\n\t'method',\n\t'preload',\n\t'scope',\n\t'shape',\n\t'spellcheck',\n\t'translate',\n\t'type',\n\t'wrap',\n] );\n\n/**\n * Set of CSS style properties which support assignment of unitless numbers.\n * Used in rendering of style properties, where `px` unit is assumed unless\n * property is included in this set or value is zero.\n *\n * Generated via:\n *\n * Object.entries( document.createElement( 'div' ).style )\n * .filter( ( [ key ] ) => (\n * ! /^(webkit|ms|moz)/.test( key ) &&\n * ( e.style[ key ] = 10 ) &&\n * e.style[ key ] === '10'\n * ) )\n * .map( ( [ key ] ) => key )\n * .sort();\n *\n * @type {Set<string>}\n */\nconst CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set( [\n\t'animation',\n\t'animationIterationCount',\n\t'baselineShift',\n\t'borderImageOutset',\n\t'borderImageSlice',\n\t'borderImageWidth',\n\t'columnCount',\n\t'cx',\n\t'cy',\n\t'fillOpacity',\n\t'flexGrow',\n\t'flexShrink',\n\t'floodOpacity',\n\t'fontWeight',\n\t'gridColumnEnd',\n\t'gridColumnStart',\n\t'gridRowEnd',\n\t'gridRowStart',\n\t'lineHeight',\n\t'opacity',\n\t'order',\n\t'orphans',\n\t'r',\n\t'rx',\n\t'ry',\n\t'shapeImageThreshold',\n\t'stopOpacity',\n\t'strokeDasharray',\n\t'strokeDashoffset',\n\t'strokeMiterlimit',\n\t'strokeOpacity',\n\t'strokeWidth',\n\t'tabSize',\n\t'widows',\n\t'x',\n\t'y',\n\t'zIndex',\n\t'zoom',\n] );\n\n/**\n * Returns true if the specified string is prefixed by one of an array of\n * possible prefixes.\n *\n * @param {string} string String to check.\n * @param {string[]} prefixes Possible prefixes.\n *\n * @return {boolean} Whether string has prefix.\n */\nexport function hasPrefix( string, prefixes ) {\n\treturn prefixes.some( ( prefix ) => string.indexOf( prefix ) === 0 );\n}\n\n/**\n * Returns true if the given prop name should be ignored in attributes\n * serialization, or false otherwise.\n *\n * @param {string} attribute Attribute to check.\n *\n * @return {boolean} Whether attribute should be ignored.\n */\nfunction isInternalAttribute( attribute ) {\n\treturn 'key' === attribute || 'children' === attribute;\n}\n\n/**\n * Returns the normal form of the element's attribute value for HTML.\n *\n * @param {string} attribute Attribute name.\n * @param {*} value Non-normalized attribute value.\n *\n * @return {*} Normalized attribute value.\n */\nfunction getNormalAttributeValue( attribute, value ) {\n\tswitch ( attribute ) {\n\t\tcase 'style':\n\t\t\treturn renderStyle( value );\n\t}\n\n\treturn value;\n}\n/**\n * This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).\n * We need this to render e.g strokeWidth as stroke-width.\n *\n * List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.\n */\nconst SVG_ATTRIBUTE_WITH_DASHES_LIST = [\n\t'accentHeight',\n\t'alignmentBaseline',\n\t'arabicForm',\n\t'baselineShift',\n\t'capHeight',\n\t'clipPath',\n\t'clipRule',\n\t'colorInterpolation',\n\t'colorInterpolationFilters',\n\t'colorProfile',\n\t'colorRendering',\n\t'dominantBaseline',\n\t'enableBackground',\n\t'fillOpacity',\n\t'fillRule',\n\t'floodColor',\n\t'floodOpacity',\n\t'fontFamily',\n\t'fontSize',\n\t'fontSizeAdjust',\n\t'fontStretch',\n\t'fontStyle',\n\t'fontVariant',\n\t'fontWeight',\n\t'glyphName',\n\t'glyphOrientationHorizontal',\n\t'glyphOrientationVertical',\n\t'horizAdvX',\n\t'horizOriginX',\n\t'imageRendering',\n\t'letterSpacing',\n\t'lightingColor',\n\t'markerEnd',\n\t'markerMid',\n\t'markerStart',\n\t'overlinePosition',\n\t'overlineThickness',\n\t'paintOrder',\n\t'panose1',\n\t'pointerEvents',\n\t'renderingIntent',\n\t'shapeRendering',\n\t'stopColor',\n\t'stopOpacity',\n\t'strikethroughPosition',\n\t'strikethroughThickness',\n\t'strokeDasharray',\n\t'strokeDashoffset',\n\t'strokeLinecap',\n\t'strokeLinejoin',\n\t'strokeMiterlimit',\n\t'strokeOpacity',\n\t'strokeWidth',\n\t'textAnchor',\n\t'textDecoration',\n\t'textRendering',\n\t'underlinePosition',\n\t'underlineThickness',\n\t'unicodeBidi',\n\t'unicodeRange',\n\t'unitsPerEm',\n\t'vAlphabetic',\n\t'vHanging',\n\t'vIdeographic',\n\t'vMathematical',\n\t'vectorEffect',\n\t'vertAdvY',\n\t'vertOriginX',\n\t'vertOriginY',\n\t'wordSpacing',\n\t'writingMode',\n\t'xmlnsXlink',\n\t'xHeight',\n].reduce( ( map, attribute ) => {\n\t// The keys are lower-cased for more robust lookup.\n\tmap[ attribute.toLowerCase() ] = attribute;\n\treturn map;\n}, {} );\n\n/**\n * This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).\n * The keys are lower-cased for more robust lookup.\n * Note that this list only contains attributes that contain at least one capital letter.\n * Lowercase attributes don't need mapping, since we lowercase all attributes by default.\n */\nconst CASE_SENSITIVE_SVG_ATTRIBUTES = [\n\t'allowReorder',\n\t'attributeName',\n\t'attributeType',\n\t'autoReverse',\n\t'baseFrequency',\n\t'baseProfile',\n\t'calcMode',\n\t'clipPathUnits',\n\t'contentScriptType',\n\t'contentStyleType',\n\t'diffuseConstant',\n\t'edgeMode',\n\t'externalResourcesRequired',\n\t'filterRes',\n\t'filterUnits',\n\t'glyphRef',\n\t'gradientTransform',\n\t'gradientUnits',\n\t'kernelMatrix',\n\t'kernelUnitLength',\n\t'keyPoints',\n\t'keySplines',\n\t'keyTimes',\n\t'lengthAdjust',\n\t'limitingConeAngle',\n\t'markerHeight',\n\t'markerUnits',\n\t'markerWidth',\n\t'maskContentUnits',\n\t'maskUnits',\n\t'numOctaves',\n\t'pathLength',\n\t'patternContentUnits',\n\t'patternTransform',\n\t'patternUnits',\n\t'pointsAtX',\n\t'pointsAtY',\n\t'pointsAtZ',\n\t'preserveAlpha',\n\t'preserveAspectRatio',\n\t'primitiveUnits',\n\t'refX',\n\t'refY',\n\t'repeatCount',\n\t'repeatDur',\n\t'requiredExtensions',\n\t'requiredFeatures',\n\t'specularConstant',\n\t'specularExponent',\n\t'spreadMethod',\n\t'startOffset',\n\t'stdDeviation',\n\t'stitchTiles',\n\t'suppressContentEditableWarning',\n\t'suppressHydrationWarning',\n\t'surfaceScale',\n\t'systemLanguage',\n\t'tableValues',\n\t'targetX',\n\t'targetY',\n\t'textLength',\n\t'viewBox',\n\t'viewTarget',\n\t'xChannelSelector',\n\t'yChannelSelector',\n].reduce( ( map, attribute ) => {\n\t// The keys are lower-cased for more robust lookup.\n\tmap[ attribute.toLowerCase() ] = attribute;\n\treturn map;\n}, {} );\n\n/**\n * This is a map of all SVG attributes that have colons.\n * Keys are lower-cased and stripped of their colons for more robust lookup.\n */\nconst SVG_ATTRIBUTES_WITH_COLONS = [\n\t'xlink:actuate',\n\t'xlink:arcrole',\n\t'xlink:href',\n\t'xlink:role',\n\t'xlink:show',\n\t'xlink:title',\n\t'xlink:type',\n\t'xml:base',\n\t'xml:lang',\n\t'xml:space',\n\t'xmlns:xlink',\n].reduce( ( map, attribute ) => {\n\tmap[ attribute.replace( ':', '' ).toLowerCase() ] = attribute;\n\treturn map;\n}, {} );\n\n/**\n * Returns the normal form of the element's attribute name for HTML.\n *\n * @param {string} attribute Non-normalized attribute name.\n *\n * @return {string} Normalized attribute name.\n */\nfunction getNormalAttributeName( attribute ) {\n\tswitch ( attribute ) {\n\t\tcase 'htmlFor':\n\t\t\treturn 'for';\n\n\t\tcase 'className':\n\t\t\treturn 'class';\n\t}\n\tconst attributeLowerCase = attribute.toLowerCase();\n\n\tif ( CASE_SENSITIVE_SVG_ATTRIBUTES[ attributeLowerCase ] ) {\n\t\treturn CASE_SENSITIVE_SVG_ATTRIBUTES[ attributeLowerCase ];\n\t} else if ( SVG_ATTRIBUTE_WITH_DASHES_LIST[ attributeLowerCase ] ) {\n\t\treturn kebabCase(\n\t\t\tSVG_ATTRIBUTE_WITH_DASHES_LIST[ attributeLowerCase ]\n\t\t);\n\t} else if ( SVG_ATTRIBUTES_WITH_COLONS[ attributeLowerCase ] ) {\n\t\treturn SVG_ATTRIBUTES_WITH_COLONS[ attributeLowerCase ];\n\t}\n\n\treturn attributeLowerCase;\n}\n\n/**\n * Returns the normal form of the style property name for HTML.\n *\n * - Converts property names to kebab-case, e.g. 'backgroundColor' → 'background-color'\n * - Leaves custom attributes alone, e.g. '--myBackgroundColor' → '--myBackgroundColor'\n * - Converts vendor-prefixed property names to -kebab-case, e.g. 'MozTransform' → '-moz-transform'\n *\n * @param {string} property Property name.\n *\n * @return {string} Normalized property name.\n */\nfunction getNormalStylePropertyName( property ) {\n\tif ( startsWith( property, '--' ) ) {\n\t\treturn property;\n\t}\n\n\tif ( hasPrefix( property, [ 'ms', 'O', 'Moz', 'Webkit' ] ) ) {\n\t\treturn '-' + kebabCase( property );\n\t}\n\n\treturn kebabCase( property );\n}\n\n/**\n * Returns the normal form of the style property value for HTML. Appends a\n * default pixel unit if numeric, not a unitless property, and not zero.\n *\n * @param {string} property Property name.\n * @param {*} value Non-normalized property value.\n *\n * @return {*} Normalized property value.\n */\nfunction getNormalStylePropertyValue( property, value ) {\n\tif (\n\t\ttypeof value === 'number' &&\n\t\t0 !== value &&\n\t\t! CSS_PROPERTIES_SUPPORTS_UNITLESS.has( property )\n\t) {\n\t\treturn value + 'px';\n\t}\n\n\treturn value;\n}\n\n/**\n * Serializes a React element to string.\n *\n * @param {import('react').ReactNode} element Element to serialize.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element.\n */\nexport function renderElement( element, context, legacyContext = {} ) {\n\tif ( null === element || undefined === element || false === element ) {\n\t\treturn '';\n\t}\n\n\tif ( Array.isArray( element ) ) {\n\t\treturn renderChildren( element, context, legacyContext );\n\t}\n\n\tswitch ( typeof element ) {\n\t\tcase 'string':\n\t\t\treturn escapeHTML( element );\n\n\t\tcase 'number':\n\t\t\treturn element.toString();\n\t}\n\n\tconst {\n\t\ttype,\n\t\tprops,\n\t} = /** @type {{type?: any, props?: any}} */ ( element );\n\n\tswitch ( type ) {\n\t\tcase StrictMode:\n\t\tcase Fragment:\n\t\t\treturn renderChildren( props.children, context, legacyContext );\n\n\t\tcase RawHTML:\n\t\t\tconst { children, ...wrapperProps } = props;\n\n\t\t\treturn renderNativeComponent(\n\t\t\t\tisEmpty( wrapperProps ) ? null : 'div',\n\t\t\t\t{\n\t\t\t\t\t...wrapperProps,\n\t\t\t\t\tdangerouslySetInnerHTML: { __html: children },\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\tswitch ( typeof type ) {\n\t\tcase 'string':\n\t\t\treturn renderNativeComponent( type, props, context, legacyContext );\n\n\t\tcase 'function':\n\t\t\tif (\n\t\t\t\ttype.prototype &&\n\t\t\t\ttypeof type.prototype.render === 'function'\n\t\t\t) {\n\t\t\t\treturn renderComponent( type, props, context, legacyContext );\n\t\t\t}\n\n\t\t\treturn renderElement(\n\t\t\t\ttype( props, legacyContext ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\tswitch ( type && type.$$typeof ) {\n\t\tcase Provider.$$typeof:\n\t\t\treturn renderChildren( props.children, props.value, legacyContext );\n\n\t\tcase Consumer.$$typeof:\n\t\t\treturn renderElement(\n\t\t\t\tprops.children( context || type._currentValue ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\n\t\tcase ForwardRef.$$typeof:\n\t\t\treturn renderElement(\n\t\t\t\ttype.render( props ),\n\t\t\t\tcontext,\n\t\t\t\tlegacyContext\n\t\t\t);\n\t}\n\n\treturn '';\n}\n\n/**\n * Serializes a native component type to string.\n *\n * @param {?string} type Native component type to serialize, or null if\n * rendering as fragment of children content.\n * @param {Object} props Props object.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element.\n */\nexport function renderNativeComponent(\n\ttype,\n\tprops,\n\tcontext,\n\tlegacyContext = {}\n) {\n\tlet content = '';\n\tif ( type === 'textarea' && props.hasOwnProperty( 'value' ) ) {\n\t\t// Textarea children can be assigned as value prop. If it is, render in\n\t\t// place of children. Ensure to omit so it is not assigned as attribute\n\t\t// as well.\n\t\tcontent = renderChildren( props.value, context, legacyContext );\n\t\tprops = omit( props, 'value' );\n\t} else if (\n\t\tprops.dangerouslySetInnerHTML &&\n\t\ttypeof props.dangerouslySetInnerHTML.__html === 'string'\n\t) {\n\t\t// Dangerous content is left unescaped.\n\t\tcontent = props.dangerouslySetInnerHTML.__html;\n\t} else if ( typeof props.children !== 'undefined' ) {\n\t\tcontent = renderChildren( props.children, context, legacyContext );\n\t}\n\n\tif ( ! type ) {\n\t\treturn content;\n\t}\n\n\tconst attributes = renderAttributes( props );\n\n\tif ( SELF_CLOSING_TAGS.has( type ) ) {\n\t\treturn '<' + type + attributes + '/>';\n\t}\n\n\treturn '<' + type + attributes + '>' + content + '</' + type + '>';\n}\n\n/** @typedef {import('./react').WPComponent} WPComponent */\n\n/**\n * Serializes a non-native component type to string.\n *\n * @param {WPComponent} Component Component type to serialize.\n * @param {Object} props Props object.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized element\n */\nexport function renderComponent(\n\tComponent,\n\tprops,\n\tcontext,\n\tlegacyContext = {}\n) {\n\tconst instance = new /** @type {import('react').ComponentClass} */ ( Component )(\n\t\tprops,\n\t\tlegacyContext\n\t);\n\n\tif (\n\t\ttypeof (\n\t\t\t// Ignore reason: Current prettier reformats parens and mangles type assertion\n\t\t\t// prettier-ignore\n\t\t\t/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext\n\t\t) === 'function'\n\t) {\n\t\tObject.assign(\n\t\t\tlegacyContext,\n\t\t\t/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext()\n\t\t);\n\t}\n\n\tconst html = renderElement( instance.render(), context, legacyContext );\n\n\treturn html;\n}\n\n/**\n * Serializes an array of children to string.\n *\n * @param {import('react').ReactNodeArray} children Children to serialize.\n * @param {Object} [context] Context object.\n * @param {Object} [legacyContext] Legacy context object.\n *\n * @return {string} Serialized children.\n */\nfunction renderChildren( children, context, legacyContext = {} ) {\n\tlet result = '';\n\n\tchildren = castArray( children );\n\n\tfor ( let i = 0; i < children.length; i++ ) {\n\t\tconst child = children[ i ];\n\n\t\tresult += renderElement( child, context, legacyContext );\n\t}\n\n\treturn result;\n}\n\n/**\n * Renders a props object as a string of HTML attributes.\n *\n * @param {Object} props Props object.\n *\n * @return {string} Attributes string.\n */\nexport function renderAttributes( props ) {\n\tlet result = '';\n\n\tfor ( const key in props ) {\n\t\tconst attribute = getNormalAttributeName( key );\n\t\tif ( ! isValidAttributeName( attribute ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet value = getNormalAttributeValue( key, props[ key ] );\n\n\t\t// If value is not of serializeable type, skip.\n\t\tif ( ! ATTRIBUTES_TYPES.has( typeof value ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Don't render internal attribute names.\n\t\tif ( isInternalAttribute( key ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isBooleanAttribute = BOOLEAN_ATTRIBUTES.has( attribute );\n\n\t\t// Boolean attribute should be omitted outright if its value is false.\n\t\tif ( isBooleanAttribute && value === false ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isMeaningfulAttribute =\n\t\t\tisBooleanAttribute ||\n\t\t\thasPrefix( key, [ 'data-', 'aria-' ] ) ||\n\t\t\tENUMERATED_ATTRIBUTES.has( attribute );\n\n\t\t// Only write boolean value as attribute if meaningful.\n\t\tif ( typeof value === 'boolean' && ! isMeaningfulAttribute ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tresult += ' ' + attribute;\n\n\t\t// Boolean attributes should write attribute name, but without value.\n\t\t// Mere presence of attribute name is effective truthiness.\n\t\tif ( isBooleanAttribute ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( typeof value === 'string' ) {\n\t\t\tvalue = escapeAttribute( value );\n\t\t}\n\n\t\tresult += '=\"' + value + '\"';\n\t}\n\n\treturn result;\n}\n\n/**\n * Renders a style object as a string attribute value.\n *\n * @param {Object} style Style object.\n *\n * @return {string} Style attribute value.\n */\nexport function renderStyle( style ) {\n\t// Only generate from object, e.g. tolerate string value.\n\tif ( ! isPlainObject( style ) ) {\n\t\treturn style;\n\t}\n\n\tlet result;\n\n\tfor ( const property in style ) {\n\t\tconst value = style[ property ];\n\t\tif ( null === value || undefined === value ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( result ) {\n\t\t\tresult += ';';\n\t\t} else {\n\t\t\tresult = '';\n\t\t}\n\n\t\tconst normalName = getNormalStylePropertyName( property );\n\t\tconst normalValue = getNormalStylePropertyValue( property, value );\n\t\tresult += normalName + ':' + normalValue;\n\t}\n\n\treturn result;\n}\n\nexport default renderElement;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.js"],"names":[],"mappings":"AAkPA;;;;;;;;GAQG;AACH,kCALW,MAAM,YACN,MAAM,EAAE,GAEP,OAAO,CAIlB;
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.js"],"names":[],"mappings":"AAkPA;;;;;;;;GAQG;AACH,kCALW,MAAM,YACN,MAAM,EAAE,GAEP,OAAO,CAIlB;AAiSD;;;;;;;;GAQG;AACH,uCANW,OAAO,OAAO,EAAE,SAAS,uCAIxB,MAAM,CAkFjB;AAED;;;;;;;;;;GAUG;AACH,4CARY,MAAM,0DAMN,MAAM,CAoCjB;AAED,2DAA2D;AAE3D;;;;;;;;;GASG;AACH,2CAPW,WAAW,mDAKV,MAAM,CA6BjB;AAyBD;;;;;;GAMG;AACH,8CAFY,MAAM,CAwDjB;AAED;;;;;;GAMG;AACH,yCAFY,MAAM,CA4BjB;;0BAhKa,OAAO,SAAS,EAAE,WAAW;wBAlnB7B,OAAO,SAAS,EAAE,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/element",
|
|
3
|
-
"version": "4.1.0",
|
|
3
|
+
"version": "4.1.3-next.a55ed9455a.0",
|
|
4
4
|
"description": "Element React module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@babel/runtime": "^7.16.0",
|
|
32
32
|
"@types/react": "^17.0.37",
|
|
33
33
|
"@types/react-dom": "^17.0.11",
|
|
34
|
-
"@wordpress/escape-html": "^2.3.0",
|
|
34
|
+
"@wordpress/escape-html": "^2.3.2-next.a55ed9455a.0",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
36
|
"react": "^17.0.2",
|
|
37
37
|
"react-dom": "^17.0.2"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "c5108185851b824d531bce55991a3589947e8551"
|
|
43
43
|
}
|
|
@@ -193,7 +193,7 @@ function proceed( conversionMap ) {
|
|
|
193
193
|
return true;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
//
|
|
196
|
+
// Otherwise we found an inner element.
|
|
197
197
|
addChild(
|
|
198
198
|
createFrame( conversionMap[ name ], startOffset, tokenLength )
|
|
199
199
|
);
|
|
@@ -214,15 +214,15 @@ function proceed( conversionMap ) {
|
|
|
214
214
|
return true;
|
|
215
215
|
|
|
216
216
|
case 'closer':
|
|
217
|
-
//
|
|
217
|
+
// If we're not nesting then this is easy - close the block.
|
|
218
218
|
if ( 1 === stackDepth ) {
|
|
219
219
|
closeOuterElement( startOffset );
|
|
220
220
|
offset = startOffset + tokenLength;
|
|
221
221
|
return true;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
//
|
|
225
|
-
// block and add it as a innerBlock to the parent
|
|
224
|
+
// Otherwise we're nested and we have to close out the current
|
|
225
|
+
// block and add it as a innerBlock to the parent.
|
|
226
226
|
const stackTop = stack.pop();
|
|
227
227
|
const text = indoc.substr(
|
|
228
228
|
stackTop.prevOffset,
|
|
@@ -256,7 +256,7 @@ function proceed( conversionMap ) {
|
|
|
256
256
|
*/
|
|
257
257
|
function nextToken() {
|
|
258
258
|
const matches = tokenizer.exec( indoc );
|
|
259
|
-
//
|
|
259
|
+
// We have no more tokens.
|
|
260
260
|
if ( null === matches ) {
|
|
261
261
|
return [ 'no-more-tokens' ];
|
|
262
262
|
}
|
package/src/serialize.js
CHANGED
|
@@ -281,6 +281,190 @@ function getNormalAttributeValue( attribute, value ) {
|
|
|
281
281
|
|
|
282
282
|
return value;
|
|
283
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* This is a map of all SVG attributes that have dashes. Map(lower case prop => dashed lower case attribute).
|
|
286
|
+
* We need this to render e.g strokeWidth as stroke-width.
|
|
287
|
+
*
|
|
288
|
+
* List from: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute.
|
|
289
|
+
*/
|
|
290
|
+
const SVG_ATTRIBUTE_WITH_DASHES_LIST = [
|
|
291
|
+
'accentHeight',
|
|
292
|
+
'alignmentBaseline',
|
|
293
|
+
'arabicForm',
|
|
294
|
+
'baselineShift',
|
|
295
|
+
'capHeight',
|
|
296
|
+
'clipPath',
|
|
297
|
+
'clipRule',
|
|
298
|
+
'colorInterpolation',
|
|
299
|
+
'colorInterpolationFilters',
|
|
300
|
+
'colorProfile',
|
|
301
|
+
'colorRendering',
|
|
302
|
+
'dominantBaseline',
|
|
303
|
+
'enableBackground',
|
|
304
|
+
'fillOpacity',
|
|
305
|
+
'fillRule',
|
|
306
|
+
'floodColor',
|
|
307
|
+
'floodOpacity',
|
|
308
|
+
'fontFamily',
|
|
309
|
+
'fontSize',
|
|
310
|
+
'fontSizeAdjust',
|
|
311
|
+
'fontStretch',
|
|
312
|
+
'fontStyle',
|
|
313
|
+
'fontVariant',
|
|
314
|
+
'fontWeight',
|
|
315
|
+
'glyphName',
|
|
316
|
+
'glyphOrientationHorizontal',
|
|
317
|
+
'glyphOrientationVertical',
|
|
318
|
+
'horizAdvX',
|
|
319
|
+
'horizOriginX',
|
|
320
|
+
'imageRendering',
|
|
321
|
+
'letterSpacing',
|
|
322
|
+
'lightingColor',
|
|
323
|
+
'markerEnd',
|
|
324
|
+
'markerMid',
|
|
325
|
+
'markerStart',
|
|
326
|
+
'overlinePosition',
|
|
327
|
+
'overlineThickness',
|
|
328
|
+
'paintOrder',
|
|
329
|
+
'panose1',
|
|
330
|
+
'pointerEvents',
|
|
331
|
+
'renderingIntent',
|
|
332
|
+
'shapeRendering',
|
|
333
|
+
'stopColor',
|
|
334
|
+
'stopOpacity',
|
|
335
|
+
'strikethroughPosition',
|
|
336
|
+
'strikethroughThickness',
|
|
337
|
+
'strokeDasharray',
|
|
338
|
+
'strokeDashoffset',
|
|
339
|
+
'strokeLinecap',
|
|
340
|
+
'strokeLinejoin',
|
|
341
|
+
'strokeMiterlimit',
|
|
342
|
+
'strokeOpacity',
|
|
343
|
+
'strokeWidth',
|
|
344
|
+
'textAnchor',
|
|
345
|
+
'textDecoration',
|
|
346
|
+
'textRendering',
|
|
347
|
+
'underlinePosition',
|
|
348
|
+
'underlineThickness',
|
|
349
|
+
'unicodeBidi',
|
|
350
|
+
'unicodeRange',
|
|
351
|
+
'unitsPerEm',
|
|
352
|
+
'vAlphabetic',
|
|
353
|
+
'vHanging',
|
|
354
|
+
'vIdeographic',
|
|
355
|
+
'vMathematical',
|
|
356
|
+
'vectorEffect',
|
|
357
|
+
'vertAdvY',
|
|
358
|
+
'vertOriginX',
|
|
359
|
+
'vertOriginY',
|
|
360
|
+
'wordSpacing',
|
|
361
|
+
'writingMode',
|
|
362
|
+
'xmlnsXlink',
|
|
363
|
+
'xHeight',
|
|
364
|
+
].reduce( ( map, attribute ) => {
|
|
365
|
+
// The keys are lower-cased for more robust lookup.
|
|
366
|
+
map[ attribute.toLowerCase() ] = attribute;
|
|
367
|
+
return map;
|
|
368
|
+
}, {} );
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* This is a map of all case-sensitive SVG attributes. Map(lowercase key => proper case attribute).
|
|
372
|
+
* The keys are lower-cased for more robust lookup.
|
|
373
|
+
* Note that this list only contains attributes that contain at least one capital letter.
|
|
374
|
+
* Lowercase attributes don't need mapping, since we lowercase all attributes by default.
|
|
375
|
+
*/
|
|
376
|
+
const CASE_SENSITIVE_SVG_ATTRIBUTES = [
|
|
377
|
+
'allowReorder',
|
|
378
|
+
'attributeName',
|
|
379
|
+
'attributeType',
|
|
380
|
+
'autoReverse',
|
|
381
|
+
'baseFrequency',
|
|
382
|
+
'baseProfile',
|
|
383
|
+
'calcMode',
|
|
384
|
+
'clipPathUnits',
|
|
385
|
+
'contentScriptType',
|
|
386
|
+
'contentStyleType',
|
|
387
|
+
'diffuseConstant',
|
|
388
|
+
'edgeMode',
|
|
389
|
+
'externalResourcesRequired',
|
|
390
|
+
'filterRes',
|
|
391
|
+
'filterUnits',
|
|
392
|
+
'glyphRef',
|
|
393
|
+
'gradientTransform',
|
|
394
|
+
'gradientUnits',
|
|
395
|
+
'kernelMatrix',
|
|
396
|
+
'kernelUnitLength',
|
|
397
|
+
'keyPoints',
|
|
398
|
+
'keySplines',
|
|
399
|
+
'keyTimes',
|
|
400
|
+
'lengthAdjust',
|
|
401
|
+
'limitingConeAngle',
|
|
402
|
+
'markerHeight',
|
|
403
|
+
'markerUnits',
|
|
404
|
+
'markerWidth',
|
|
405
|
+
'maskContentUnits',
|
|
406
|
+
'maskUnits',
|
|
407
|
+
'numOctaves',
|
|
408
|
+
'pathLength',
|
|
409
|
+
'patternContentUnits',
|
|
410
|
+
'patternTransform',
|
|
411
|
+
'patternUnits',
|
|
412
|
+
'pointsAtX',
|
|
413
|
+
'pointsAtY',
|
|
414
|
+
'pointsAtZ',
|
|
415
|
+
'preserveAlpha',
|
|
416
|
+
'preserveAspectRatio',
|
|
417
|
+
'primitiveUnits',
|
|
418
|
+
'refX',
|
|
419
|
+
'refY',
|
|
420
|
+
'repeatCount',
|
|
421
|
+
'repeatDur',
|
|
422
|
+
'requiredExtensions',
|
|
423
|
+
'requiredFeatures',
|
|
424
|
+
'specularConstant',
|
|
425
|
+
'specularExponent',
|
|
426
|
+
'spreadMethod',
|
|
427
|
+
'startOffset',
|
|
428
|
+
'stdDeviation',
|
|
429
|
+
'stitchTiles',
|
|
430
|
+
'suppressContentEditableWarning',
|
|
431
|
+
'suppressHydrationWarning',
|
|
432
|
+
'surfaceScale',
|
|
433
|
+
'systemLanguage',
|
|
434
|
+
'tableValues',
|
|
435
|
+
'targetX',
|
|
436
|
+
'targetY',
|
|
437
|
+
'textLength',
|
|
438
|
+
'viewBox',
|
|
439
|
+
'viewTarget',
|
|
440
|
+
'xChannelSelector',
|
|
441
|
+
'yChannelSelector',
|
|
442
|
+
].reduce( ( map, attribute ) => {
|
|
443
|
+
// The keys are lower-cased for more robust lookup.
|
|
444
|
+
map[ attribute.toLowerCase() ] = attribute;
|
|
445
|
+
return map;
|
|
446
|
+
}, {} );
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* This is a map of all SVG attributes that have colons.
|
|
450
|
+
* Keys are lower-cased and stripped of their colons for more robust lookup.
|
|
451
|
+
*/
|
|
452
|
+
const SVG_ATTRIBUTES_WITH_COLONS = [
|
|
453
|
+
'xlink:actuate',
|
|
454
|
+
'xlink:arcrole',
|
|
455
|
+
'xlink:href',
|
|
456
|
+
'xlink:role',
|
|
457
|
+
'xlink:show',
|
|
458
|
+
'xlink:title',
|
|
459
|
+
'xlink:type',
|
|
460
|
+
'xml:base',
|
|
461
|
+
'xml:lang',
|
|
462
|
+
'xml:space',
|
|
463
|
+
'xmlns:xlink',
|
|
464
|
+
].reduce( ( map, attribute ) => {
|
|
465
|
+
map[ attribute.replace( ':', '' ).toLowerCase() ] = attribute;
|
|
466
|
+
return map;
|
|
467
|
+
}, {} );
|
|
284
468
|
|
|
285
469
|
/**
|
|
286
470
|
* Returns the normal form of the element's attribute name for HTML.
|
|
@@ -297,8 +481,19 @@ function getNormalAttributeName( attribute ) {
|
|
|
297
481
|
case 'className':
|
|
298
482
|
return 'class';
|
|
299
483
|
}
|
|
484
|
+
const attributeLowerCase = attribute.toLowerCase();
|
|
485
|
+
|
|
486
|
+
if ( CASE_SENSITIVE_SVG_ATTRIBUTES[ attributeLowerCase ] ) {
|
|
487
|
+
return CASE_SENSITIVE_SVG_ATTRIBUTES[ attributeLowerCase ];
|
|
488
|
+
} else if ( SVG_ATTRIBUTE_WITH_DASHES_LIST[ attributeLowerCase ] ) {
|
|
489
|
+
return kebabCase(
|
|
490
|
+
SVG_ATTRIBUTE_WITH_DASHES_LIST[ attributeLowerCase ]
|
|
491
|
+
);
|
|
492
|
+
} else if ( SVG_ATTRIBUTES_WITH_COLONS[ attributeLowerCase ] ) {
|
|
493
|
+
return SVG_ATTRIBUTES_WITH_COLONS[ attributeLowerCase ];
|
|
494
|
+
}
|
|
300
495
|
|
|
301
|
-
return
|
|
496
|
+
return attributeLowerCase;
|
|
302
497
|
}
|
|
303
498
|
|
|
304
499
|
/**
|
package/src/test/serialize.js
CHANGED
|
@@ -181,6 +181,42 @@ describe( 'renderElement()', () => {
|
|
|
181
181
|
expect( result ).toBe( 'hello<div></div>' );
|
|
182
182
|
} );
|
|
183
183
|
|
|
184
|
+
it( 'SVG attributes with dashes should be rendered as such - even with wrong casing', () => {
|
|
185
|
+
const result = renderElement(
|
|
186
|
+
<svg>
|
|
187
|
+
<rect x="0" y="0" strokeWidth="5" STROKELinejoin="miter"></rect>
|
|
188
|
+
</svg>
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
expect( result ).toBe(
|
|
192
|
+
'<svg><rect x="0" y="0" stroke-width="5" stroke-linejoin="miter"></rect></svg>'
|
|
193
|
+
);
|
|
194
|
+
} );
|
|
195
|
+
|
|
196
|
+
it( 'Case sensitive attributes should have the right casing - even with wrong casing', () => {
|
|
197
|
+
const result = renderElement(
|
|
198
|
+
<svg ViEWBOx="0 0 1 1" preserveAsPECTRatio="slice"></svg>
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
expect( result ).toBe(
|
|
202
|
+
'<svg viewBox="0 0 1 1" preserveAspectRatio="slice"></svg>'
|
|
203
|
+
);
|
|
204
|
+
} );
|
|
205
|
+
|
|
206
|
+
it( 'SVG attributes with colons should be rendered as such - even with wrong casing', () => {
|
|
207
|
+
const result = renderElement(
|
|
208
|
+
<svg
|
|
209
|
+
viewBox="0 0 1 1"
|
|
210
|
+
XLINKROLE="some-role"
|
|
211
|
+
xlinkShow="hello"
|
|
212
|
+
></svg>
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
expect( result ).toBe(
|
|
216
|
+
'<svg viewBox="0 0 1 1" xlink:role="some-role" xlink:show="hello"></svg>'
|
|
217
|
+
);
|
|
218
|
+
} );
|
|
219
|
+
|
|
184
220
|
it( 'renders escaped string element', () => {
|
|
185
221
|
const result = renderElement( 'hello & world & friends <img/>' );
|
|
186
222
|
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/@types/react/global.d.ts","../../node_modules/@types/react/node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/scheduler/tracing.d.ts","../../node_modules/@types/react/index.d.ts","../../node_modules/@types/lodash/common/common.d.ts","../../node_modules/@types/lodash/common/array.d.ts","../../node_modules/@types/lodash/common/collection.d.ts","../../node_modules/@types/lodash/common/date.d.ts","../../node_modules/@types/lodash/common/function.d.ts","../../node_modules/@types/lodash/common/lang.d.ts","../../node_modules/@types/lodash/common/math.d.ts","../../node_modules/@types/lodash/common/number.d.ts","../../node_modules/@types/lodash/common/object.d.ts","../../node_modules/@types/lodash/common/seq.d.ts","../../node_modules/@types/lodash/common/string.d.ts","../../node_modules/@types/lodash/common/util.d.ts","../../node_modules/@types/lodash/index.d.ts","./src/react.js","./src/create-interpolate-element.js","../../node_modules/@types/react-dom/index.d.ts","./src/react-platform.js","./src/utils.js","./src/platform.js","../escape-html/build-types/index.d.ts","./src/raw-html.js","./src/serialize.js","./src/index.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},{"version":"ecf78e637f710f340ec08d5d92b3f31b134a46a4fcf2e758690d8c46ce62cba6","affectsGlobalScope":true},"381899b8d1d4c1be716f18cb5242ba39f66f4b1e31d45af62a32a99f8edcb39d","f7b46d22a307739c145e5fddf537818038fdfffd580d79ed717f4d4d37249380","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"1bc82f5b3bb93df76d19730c84467b0b346187198537135d63a672956f323720","affectsGlobalScope":true},"675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","9fa6b83a35e897f340858995ca5d77e901d89fd18644cd4c9e8a4afe0b2e6363",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"4fa69ebb7af909f4f767f487cba9cb09623fb626a470562f419128145ada49f2","85033f9a470234f884ee03fbb16e38c14198c1d3793c4f2fe42a001ee0cfc89f","45a63e17814c570ea59407f231ef9c561510bd6edb36f17479b09b44619496c6","5f64b816787e27a185108a1cb5a3b2843975b2924cf4f364609f5a21d46f7c0e","70f5fb0dd6739831c8fb7ca0c972fcf523fef17230dd2f54aa9dd9c065141979","36af408a1aedb7ef10cb8d8c8a1474883330805d09c17f080887143602cf9f77","a2619dc7f465db880771e5b7a505b668319ae3e72a05f3d2dc00f7303decc6ec","f3053e00b1c9034866070bfc7af4030ab60947997ce959bb20cd8f3b99ad556e","b0242dc6c8c1f5c953d1c0475440af6b9c0be2b6b64dacf2d35cec3ec52fccdb","e2877cc0e5f7bb33c7751b0e66c102d26cb2423e65908fde2ed3093d571ee264"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitAny":false,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"strictNullChecks":false,"target":99},"fileIdsList":[[50,52,53,54,55,56,57,58,59,60,61,62],[50,51,53,54,55,56,57,58,59,60,61,62],[51,52,53,54,55,56,57,58,59,60,61,62],[50,51,52,54,55,56,57,58,59,60,61,62],[50,51,52,53,55,56,57,58,59,60,61,62],[50,51,52,53,54,56,57,58,59,60,61,62],[50,51,52,53,54,55,57,58,59,60,61,62],[50,51,52,53,54,55,56,58,59,60,61,62],[50,51,52,53,54,55,56,57,59,60,61,62],[50,51,52,53,54,55,56,57,58,60,61,62],[50,51,52,53,54,55,56,57,58,59,61,62],[50,51,52,53,54,55,56,57,58,59,60,62],[50,51,52,53,54,55,56,57,58,59,60,61],[49],[45,46,47,48],[63],[63,64,66,67,68,70,71],[49,63],[63,65],[49,62],[49,62,63,69,70],[62]],"referencedMap":[[51,1],[52,2],[50,3],[53,4],[54,5],[55,6],[56,7],[57,8],[58,9],[59,10],[60,11],[61,12],[62,13],[65,14],[49,15],[64,16],[72,17],[70,18],[66,19],[63,20],[71,21],[67,22]],"exportedModulesMap":[[51,1],[52,2],[50,3],[53,4],[54,5],[55,6],[56,7],[57,8],[58,9],[59,10],[60,11],[61,12],[62,13],[65,14],[49,15],[64,16],[72,17],[70,18],[66,19],[63,20],[71,21],[67,22]],"semanticDiagnosticsPerFile":[51,52,50,53,54,55,56,57,58,59,60,61,62,47,65,45,49,46,48,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,64,72,68,70,66,63,71,67,69]},"version":"4.4.2"}
|
|
1
|
+
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/@types/react/global.d.ts","../../node_modules/@types/react/node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/scheduler/tracing.d.ts","../../node_modules/@types/react/index.d.ts","../../node_modules/@types/lodash/common/common.d.ts","../../node_modules/@types/lodash/common/array.d.ts","../../node_modules/@types/lodash/common/collection.d.ts","../../node_modules/@types/lodash/common/date.d.ts","../../node_modules/@types/lodash/common/function.d.ts","../../node_modules/@types/lodash/common/lang.d.ts","../../node_modules/@types/lodash/common/math.d.ts","../../node_modules/@types/lodash/common/number.d.ts","../../node_modules/@types/lodash/common/object.d.ts","../../node_modules/@types/lodash/common/seq.d.ts","../../node_modules/@types/lodash/common/string.d.ts","../../node_modules/@types/lodash/common/util.d.ts","../../node_modules/@types/lodash/index.d.ts","./src/react.js","./src/create-interpolate-element.js","../../node_modules/@types/react-dom/index.d.ts","./src/react-platform.js","./src/utils.js","./src/platform.js","../escape-html/build-types/index.d.ts","./src/raw-html.js","./src/serialize.js","./src/index.js"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},{"version":"ecf78e637f710f340ec08d5d92b3f31b134a46a4fcf2e758690d8c46ce62cba6","affectsGlobalScope":true},"381899b8d1d4c1be716f18cb5242ba39f66f4b1e31d45af62a32a99f8edcb39d","f7b46d22a307739c145e5fddf537818038fdfffd580d79ed717f4d4d37249380","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"1bc82f5b3bb93df76d19730c84467b0b346187198537135d63a672956f323720","affectsGlobalScope":true},"675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","c24ad9be9adf28f0927e3d9d9e9cec1c677022356f241ccbbfb97bfe8fb3d1a1","0ec0998e2d085e8ea54266f547976ae152c9dd6cdb9ac4d8a520a230f5ebae84","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3e59f00ab03c33717b3130066d4debb272da90eeded4935ff0604c2bc25a5cae","9fa6b83a35e897f340858995ca5d77e901d89fd18644cd4c9e8a4afe0b2e6363",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"4fa69ebb7af909f4f767f487cba9cb09623fb626a470562f419128145ada49f2","0dffc5330b16e7ae0df3c3840e35bf028906342bbd2530e83d194a5a25ff40ed","45a63e17814c570ea59407f231ef9c561510bd6edb36f17479b09b44619496c6","5f64b816787e27a185108a1cb5a3b2843975b2924cf4f364609f5a21d46f7c0e","70f5fb0dd6739831c8fb7ca0c972fcf523fef17230dd2f54aa9dd9c065141979","36af408a1aedb7ef10cb8d8c8a1474883330805d09c17f080887143602cf9f77","a2619dc7f465db880771e5b7a505b668319ae3e72a05f3d2dc00f7303decc6ec","f3053e00b1c9034866070bfc7af4030ab60947997ce959bb20cd8f3b99ad556e","145c2b83a8655a074054f55a6c132c09cd8e27a882cda86e8c68c79f153523d9","e2877cc0e5f7bb33c7751b0e66c102d26cb2423e65908fde2ed3093d571ee264"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitAny":false,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"strictNullChecks":false,"target":99},"fileIdsList":[[50,52,53,54,55,56,57,58,59,60,61,62],[50,51,53,54,55,56,57,58,59,60,61,62],[51,52,53,54,55,56,57,58,59,60,61,62],[50,51,52,54,55,56,57,58,59,60,61,62],[50,51,52,53,55,56,57,58,59,60,61,62],[50,51,52,53,54,56,57,58,59,60,61,62],[50,51,52,53,54,55,57,58,59,60,61,62],[50,51,52,53,54,55,56,58,59,60,61,62],[50,51,52,53,54,55,56,57,59,60,61,62],[50,51,52,53,54,55,56,57,58,60,61,62],[50,51,52,53,54,55,56,57,58,59,61,62],[50,51,52,53,54,55,56,57,58,59,60,62],[50,51,52,53,54,55,56,57,58,59,60,61],[49],[45,46,47,48],[63],[63,64,66,67,68,70,71],[49,63],[63,65],[49,62],[49,62,63,69,70],[62]],"referencedMap":[[51,1],[52,2],[50,3],[53,4],[54,5],[55,6],[56,7],[57,8],[58,9],[59,10],[60,11],[61,12],[62,13],[65,14],[49,15],[64,16],[72,17],[70,18],[66,19],[63,20],[71,21],[67,22]],"exportedModulesMap":[[51,1],[52,2],[50,3],[53,4],[54,5],[55,6],[56,7],[57,8],[58,9],[59,10],[60,11],[61,12],[62,13],[65,14],[49,15],[64,16],[72,17],[70,18],[66,19],[63,20],[71,21],[67,22]],"semanticDiagnosticsPerFile":[51,52,50,53,54,55,56,57,58,59,60,61,62,47,65,45,49,46,48,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,64,72,68,70,66,63,71,67,69]},"version":"4.4.2"}
|