Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/element

Package Overview
Dependencies
Maintainers
14
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/element - npm Package Compare versions

Comparing version 2.12.0 to 2.13.0

build-types/create-interpolate-element.d.ts

50

build-module/create-interpolate-element.js

@@ -9,2 +9,4 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";

import { createElement, cloneElement, Fragment, isValidElement } from 'react';
/** @typedef {import('./react').WPElement} WPElement */
var indoc, offset, output, stack;

@@ -29,2 +31,20 @@ /**

/**
* The stack frame tracking parse progress.
*
* @typedef Frame
*
* @property {WPElement} element A parent element which may still have
* @property {number} tokenStart Offset at which parent element first
* appears.
* @property {number} tokenLength Length of string marking start of parent
* element.
* @property {number} [prevOffset] Running offset at which parsing should
* continue.
* @property {number} [leadingTextStart] Offset at which last closing element
* finished, used for finding text between
* elements.
* @property {WPElement[]} children Children.
*/
/**
* Tracks recursive-descent parse state.

@@ -36,13 +56,13 @@ *

* @private
* @param {WPElement} element A parent element which may still have
* nested children not yet parsed.
* @param {number} tokenStart Offset at which parent element first
* appears.
* @param {number} tokenLength Length of string marking start of parent
* element.
* @param {number} prevOffset Running offset at which parsing should
* continue.
* @param {number} leadingTextStart Offset at which last closing element
* finished, used for finding text between
* elements
* @param {WPElement} element A parent element which may still have
* nested children not yet parsed.
* @param {number} tokenStart Offset at which parent element first
* appears.
* @param {number} tokenLength Length of string marking start of parent
* element.
* @param {number} [prevOffset] Running offset at which parsing should
* continue.
* @param {number} [leadingTextStart] Offset at which last closing element
* finished, used for finding text between
* elements.
*

@@ -52,3 +72,3 @@ * @return {Frame} The stack frame tracking parse progress.

function Frame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
return {

@@ -182,3 +202,3 @@ element: element,

addChild(new Frame(conversionMap[name], startOffset, tokenLength));
addChild(createFrame(conversionMap[name], startOffset, tokenLength));
offset = startOffset + tokenLength;

@@ -188,3 +208,3 @@ return true;

case 'opener':
stack.push(new Frame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart));
stack.push(createFrame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart));
offset = startOffset + tokenLength;

@@ -207,3 +227,3 @@ return true;

stackTop.prevOffset = startOffset + tokenLength;
var frame = new Frame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
var frame = createFrame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
frame.children = stackTop.children;

@@ -210,0 +230,0 @@ addChild(frame);

@@ -11,3 +11,10 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

*/
import { createElement } from './react';
import { createElement } from './react'; // Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly.
/* eslint-disable jsdoc/valid-types */
/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
/* eslint-enable jsdoc/valid-types */
/**

@@ -19,7 +26,6 @@ * Component used as equivalent of Fragment with unescaped HTML, in cases where

*
* @param {Object} props
* @param {string} props.children HTML to render.
* @param {Object} props.props Any additonal props to be set on the containing div.
* @param {RawHTMLProps} props Children should be a string of HTML. Other props
* will be passed through to div wrapper.
*
* @return {WPComponent} Dangerously-rendering component.
* @return {JSX.Element} Dangerously-rendering component.
*/

@@ -26,0 +32,0 @@

@@ -10,3 +10,3 @@ /**

*
* @param {WPElement} child Any renderable child, such as an element,
* @param {import('./react').WPElement} child Any renderable child, such as an element,
* string, or fragment.

@@ -20,3 +20,3 @@ * @param {HTMLElement} container DOM node into which element should be rendered.

*
* @param {WPComponent} component Component's instance.
* @param {import('./react').WPComponent} component Component's instance.
*/

@@ -28,3 +28,3 @@

*
* @param {WPElement} element Element to render.
* @param {import('./react').WPElement} element Element to render.
* @param {HTMLElement} target DOM node into which element should be rendered.

@@ -31,0 +31,0 @@ */

@@ -22,3 +22,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

*
* @typedef {import('react').Component} WPComponent
* @typedef {import('react').ComponentType} WPComponent
*/

@@ -25,0 +25,0 @@

@@ -51,4 +51,5 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import RawHTML from './raw-html';
/** @typedef {import('./react').WPElement} WPElement */
var _createContext = createContext(),
var _createContext = createContext(undefined),
Provider = _createContext.Provider,

@@ -63,3 +64,3 @@ Consumer = _createContext.Consumer;

*
* @type {Set}
* @type {Set<string>}
*/

@@ -71,3 +72,3 @@

*
* @type {Set}
* @type {Set<string>}
*/

@@ -89,3 +90,3 @@

*
* @type {Set}
* @type {Set<string>}
*/

@@ -112,3 +113,3 @@

*
* @type {Set}
* @type {Set<string>}
*/

@@ -133,3 +134,3 @@

*
* @type {Set}
* @type {Set<string>}
*/

@@ -171,3 +172,3 @@

*
* @return {string} Normalized attribute value.
* @return {*} Normalized attribute value.
*/

@@ -249,5 +250,5 @@

*
* @param {WPElement} element Element to serialize.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {import('react').ReactNode} element Element to serialize.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -277,3 +278,5 @@ * @return {string} Serialized element.

var type = element.type,
var type =
/** @type {{type?: any, props?: any}} */
element.type,
props = element.props;

@@ -325,7 +328,7 @@

*
* @param {?string} type Native component type to serialize, or null if
* rendering as fragment of children content.
* @param {Object} props Props object.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {?string} type Native component type to serialize, or null if
* rendering as fragment of children content.
* @param {Object} props Props object.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -364,9 +367,11 @@ * @return {string} Serialized element.

}
/** @typedef {import('./react').WPComponent} WPComponent */
/**
* Serializes a non-native component type to string.
*
* @param {Function} Component Component type to serialize.
* @param {Object} props Props object.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {WPComponent} Component Component type to serialize.
* @param {Object} props Props object.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -378,6 +383,14 @@ * @return {string} Serialized element

var legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var instance = new Component(props, legacyContext);
var instance = new
/** @type {import('react').ComponentClass} */
Component(props, legacyContext);
if (typeof instance.getChildContext === 'function') {
Object.assign(legacyContext, instance.getChildContext());
if (typeof // Ignore reason: Current prettier reformats parens and mangles type assertion
// prettier-ignore
/** @type {{getChildContext?: () => unknown}} */
instance.getChildContext === 'function') {
Object.assign(legacyContext,
/** @type {{getChildContext?: () => unknown}} */
instance.getChildContext());
}

@@ -391,5 +404,5 @@

*
* @param {Array} children Children to serialize.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {import('react').ReactNodeArray} children Children to serialize.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -396,0 +409,0 @@ * @return {string} Serialized children.

@@ -21,2 +21,4 @@ "use strict";

*/
/** @typedef {import('./react').WPElement} WPElement */
var indoc, offset, output, stack;

@@ -41,2 +43,20 @@ /**

/**
* The stack frame tracking parse progress.
*
* @typedef Frame
*
* @property {WPElement} element A parent element which may still have
* @property {number} tokenStart Offset at which parent element first
* appears.
* @property {number} tokenLength Length of string marking start of parent
* element.
* @property {number} [prevOffset] Running offset at which parsing should
* continue.
* @property {number} [leadingTextStart] Offset at which last closing element
* finished, used for finding text between
* elements.
* @property {WPElement[]} children Children.
*/
/**
* Tracks recursive-descent parse state.

@@ -48,13 +68,13 @@ *

* @private
* @param {WPElement} element A parent element which may still have
* nested children not yet parsed.
* @param {number} tokenStart Offset at which parent element first
* appears.
* @param {number} tokenLength Length of string marking start of parent
* element.
* @param {number} prevOffset Running offset at which parsing should
* continue.
* @param {number} leadingTextStart Offset at which last closing element
* finished, used for finding text between
* elements
* @param {WPElement} element A parent element which may still have
* nested children not yet parsed.
* @param {number} tokenStart Offset at which parent element first
* appears.
* @param {number} tokenLength Length of string marking start of parent
* element.
* @param {number} [prevOffset] Running offset at which parsing should
* continue.
* @param {number} [leadingTextStart] Offset at which last closing element
* finished, used for finding text between
* elements.
*

@@ -64,3 +84,3 @@ * @return {Frame} The stack frame tracking parse progress.

function Frame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
function createFrame(element, tokenStart, tokenLength, prevOffset, leadingTextStart) {
return {

@@ -194,3 +214,3 @@ element: element,

addChild(new Frame(conversionMap[name], startOffset, tokenLength));
addChild(createFrame(conversionMap[name], startOffset, tokenLength));
offset = startOffset + tokenLength;

@@ -200,3 +220,3 @@ return true;

case 'opener':
stack.push(new Frame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart));
stack.push(createFrame(conversionMap[name], startOffset, tokenLength, startOffset + tokenLength, leadingTextStart));
offset = startOffset + tokenLength;

@@ -219,3 +239,3 @@ return true;

stackTop.prevOffset = startOffset + tokenLength;
var frame = new Frame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
var frame = createFrame(stackTop.element, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
frame.children = stackTop.children;

@@ -222,0 +242,0 @@ addChild(frame);

@@ -20,2 +20,10 @@ "use strict";

// Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly.
/* eslint-disable jsdoc/valid-types */
/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
/* eslint-enable jsdoc/valid-types */
/**

@@ -27,7 +35,6 @@ * Component used as equivalent of Fragment with unescaped HTML, in cases where

*
* @param {Object} props
* @param {string} props.children HTML to render.
* @param {Object} props.props Any additonal props to be set on the containing div.
* @param {RawHTMLProps} props Children should be a string of HTML. Other props
* will be passed through to div wrapper.
*
* @return {WPComponent} Dangerously-rendering component.
* @return {JSX.Element} Dangerously-rendering component.
*/

@@ -34,0 +41,0 @@ function RawHTML(_ref) {

@@ -34,3 +34,4 @@ "use strict";

var _createContext = (0, _react.createContext)(),
/** @typedef {import('./react').WPElement} WPElement */
var _createContext = (0, _react.createContext)(undefined),
Provider = _createContext.Provider,

@@ -45,3 +46,3 @@ Consumer = _createContext.Consumer;

*
* @type {Set}
* @type {Set<string>}
*/

@@ -53,3 +54,3 @@

*
* @type {Set}
* @type {Set<string>}
*/

@@ -71,3 +72,3 @@

*
* @type {Set}
* @type {Set<string>}
*/

@@ -94,3 +95,3 @@

*
* @type {Set}
* @type {Set<string>}
*/

@@ -115,3 +116,3 @@

*
* @type {Set}
* @type {Set<string>}
*/

@@ -154,3 +155,3 @@

*
* @return {string} Normalized attribute value.
* @return {*} Normalized attribute value.
*/

@@ -232,5 +233,5 @@

*
* @param {WPElement} element Element to serialize.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {import('react').ReactNode} element Element to serialize.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -260,3 +261,5 @@ * @return {string} Serialized element.

var type = element.type,
var type =
/** @type {{type?: any, props?: any}} */
element.type,
props = element.props;

@@ -307,7 +310,7 @@

*
* @param {?string} type Native component type to serialize, or null if
* rendering as fragment of children content.
* @param {Object} props Props object.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {?string} type Native component type to serialize, or null if
* rendering as fragment of children content.
* @param {Object} props Props object.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -347,9 +350,11 @@ * @return {string} Serialized element.

}
/** @typedef {import('./react').WPComponent} WPComponent */
/**
* Serializes a non-native component type to string.
*
* @param {Function} Component Component type to serialize.
* @param {Object} props Props object.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {WPComponent} Component Component type to serialize.
* @param {Object} props Props object.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -362,6 +367,14 @@ * @return {string} Serialized element

var legacyContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var instance = new Component(props, legacyContext);
var instance = new
/** @type {import('react').ComponentClass} */
Component(props, legacyContext);
if (typeof instance.getChildContext === 'function') {
Object.assign(legacyContext, instance.getChildContext());
if (typeof // Ignore reason: Current prettier reformats parens and mangles type assertion
// prettier-ignore
/** @type {{getChildContext?: () => unknown}} */
instance.getChildContext === 'function') {
Object.assign(legacyContext,
/** @type {{getChildContext?: () => unknown}} */
instance.getChildContext());
}

@@ -375,5 +388,5 @@

*
* @param {Array} children Children to serialize.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {import('react').ReactNodeArray} children Children to serialize.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -380,0 +393,0 @@ * @return {string} Serialized children.

## Master
- Include TypeScript type declarations ([#21248](https://github.com/WordPress/gutenberg/pull/21248))
- Graduated `__experimentalCreateInterpolateElement` function to stable api: `createInterpolateElement` (see [20699](https://github.com/WordPress/gutenberg/pull/20699))

@@ -4,0 +5,0 @@

{
"name": "@wordpress/element",
"version": "2.12.0",
"version": "2.13.0",
"description": "Element React module for WordPress.",

@@ -24,6 +24,7 @@ "author": "The WordPress Contributors",

"react-native": "src/index",
"types": "build-types",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "^7.8.3",
"@wordpress/escape-html": "^1.7.0",
"@babel/runtime": "^7.9.2",
"@wordpress/escape-html": "^1.8.0",
"lodash": "^4.17.15",

@@ -36,3 +37,3 @@ "react": "^16.9.0",

},
"gitHead": "6e2ca778fb69c67188479b491cf2e802011d72e2"
"gitHead": "65dbf3a9503402ca3837090dc89d0207f7d96352"
}

@@ -183,3 +183,3 @@ # Element

- _child_ `WPElement`: Any renderable child, such as an element, string, or fragment.
- _child_ (unknown type): Any renderable child, such as an element, string, or fragment.
- _container_ `HTMLElement`: DOM node into which element should be rendered.

@@ -203,3 +203,3 @@

- _component_ `WPComponent`: Component's instance.
- _component_ (unknown type): Component's instance.

@@ -294,9 +294,7 @@ <a name="forwardRef" href="#forwardRef">#</a> **forwardRef**

- _props_ `Object`:
- _props.children_ `string`: HTML to render.
- _props.props_ `Object`: Any additonal props to be set on the containing div.
- _props_ `RawHTMLProps`: Children should be a string of HTML. Other props will be passed through to div wrapper.
_Returns_
- `WPComponent`: Dangerously-rendering component.
- `JSX.Element`: Dangerously-rendering component.

@@ -309,3 +307,3 @@ <a name="render" href="#render">#</a> **render**

- _element_ `WPElement`: Element to render.
- _element_ (unknown type): Element to render.
- _target_ `HTMLElement`: DOM node into which element should be rendered.

@@ -319,5 +317,5 @@

- _element_ `WPElement`: Element to serialize.
- _context_ `?Object`: Context object.
- _legacyContext_ `?Object`: Legacy context object.
- _element_ (unknown type): Element to serialize.
- _context_ `[Object]`: Context object.
- _legacyContext_ `[Object]`: Legacy context object.

@@ -324,0 +322,0 @@ _Returns_

@@ -6,2 +6,4 @@ /**

/** @typedef {import('./react').WPElement} WPElement */
let indoc, offset, output, stack;

@@ -27,2 +29,20 @@

/**
* The stack frame tracking parse progress.
*
* @typedef Frame
*
* @property {WPElement} element A parent element which may still have
* @property {number} tokenStart Offset at which parent element first
* appears.
* @property {number} tokenLength Length of string marking start of parent
* element.
* @property {number} [prevOffset] Running offset at which parsing should
* continue.
* @property {number} [leadingTextStart] Offset at which last closing element
* finished, used for finding text between
* elements.
* @property {WPElement[]} children Children.
*/
/**
* Tracks recursive-descent parse state.

@@ -34,17 +54,17 @@ *

* @private
* @param {WPElement} element A parent element which may still have
* nested children not yet parsed.
* @param {number} tokenStart Offset at which parent element first
* appears.
* @param {number} tokenLength Length of string marking start of parent
* element.
* @param {number} prevOffset Running offset at which parsing should
* continue.
* @param {number} leadingTextStart Offset at which last closing element
* finished, used for finding text between
* elements
* @param {WPElement} element A parent element which may still have
* nested children not yet parsed.
* @param {number} tokenStart Offset at which parent element first
* appears.
* @param {number} tokenLength Length of string marking start of parent
* element.
* @param {number} [prevOffset] Running offset at which parsing should
* continue.
* @param {number} [leadingTextStart] Offset at which last closing element
* finished, used for finding text between
* elements.
*
* @return {Frame} The stack frame tracking parse progress.
*/
function Frame(
function createFrame(
element,

@@ -181,3 +201,3 @@ tokenStart,

addChild(
new Frame( conversionMap[ name ], startOffset, tokenLength )
createFrame( conversionMap[ name ], startOffset, tokenLength )
);

@@ -189,3 +209,3 @@ offset = startOffset + tokenLength;

stack.push(
new Frame(
createFrame(
conversionMap[ name ],

@@ -218,3 +238,3 @@ startOffset,

stackTop.prevOffset = startOffset + tokenLength;
const frame = new Frame(
const frame = createFrame(
stackTop.element,

@@ -221,0 +241,0 @@ stackTop.tokenStart,

@@ -6,2 +6,7 @@ /**

// Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly.
/* eslint-disable jsdoc/valid-types */
/** @typedef {{children: string} & import('react').ComponentPropsWithoutRef<'div'>} RawHTMLProps */
/* eslint-enable jsdoc/valid-types */
/**

@@ -13,7 +18,6 @@ * Component used as equivalent of Fragment with unescaped HTML, in cases where

*
* @param {Object} props
* @param {string} props.children HTML to render.
* @param {Object} props.props Any additonal props to be set on the containing div.
* @param {RawHTMLProps} props Children should be a string of HTML. Other props
* will be passed through to div wrapper.
*
* @return {WPComponent} Dangerously-rendering component.
* @return {JSX.Element} Dangerously-rendering component.
*/

@@ -20,0 +24,0 @@ export default function RawHTML( { children, ...props } ) {

@@ -16,3 +16,3 @@ /**

*
* @param {WPElement} child Any renderable child, such as an element,
* @param {import('./react').WPElement} child Any renderable child, such as an element,
* string, or fragment.

@@ -26,3 +26,3 @@ * @param {HTMLElement} container DOM node into which element should be rendered.

*
* @param {WPComponent} component Component's instance.
* @param {import('./react').WPComponent} component Component's instance.
*/

@@ -34,3 +34,3 @@ export { findDOMNode };

*
* @param {WPElement} element Element to render.
* @param {import('./react').WPElement} element Element to render.
* @param {HTMLElement} target DOM node into which element should be rendered.

@@ -37,0 +37,0 @@ */

@@ -40,3 +40,3 @@ /**

*
* @typedef {import('react').Component} WPComponent
* @typedef {import('react').ComponentType} WPComponent
*/

@@ -43,0 +43,0 @@

@@ -55,3 +55,5 @@ /**

const { Provider, Consumer } = createContext();
/** @typedef {import('./react').WPElement} WPElement */
const { Provider, Consumer } = createContext( undefined );
const ForwardRef = forwardRef( () => {

@@ -64,3 +66,3 @@ return null;

*
* @type {Set}
* @type {Set<string>}
*/

@@ -72,3 +74,3 @@ const ATTRIBUTES_TYPES = new Set( [ 'string', 'boolean', 'number' ] );

*
* @type {Set}
* @type {Set<string>}
*/

@@ -107,3 +109,3 @@ const SELF_CLOSING_TAGS = new Set( [

*
* @type {Set}
* @type {Set<string>}
*/

@@ -159,3 +161,3 @@ const BOOLEAN_ATTRIBUTES = new Set( [

*
* @type {Set}
* @type {Set<string>}
*/

@@ -203,3 +205,3 @@ const ENUMERATED_ATTRIBUTES = new Set( [

*
* @type {Set}
* @type {Set<string>}
*/

@@ -278,3 +280,3 @@ const CSS_PROPERTIES_SUPPORTS_UNITLESS = new Set( [

*
* @return {string} Normalized attribute value.
* @return {*} Normalized attribute value.
*/

@@ -356,5 +358,5 @@ function getNormalAttributeValue( attribute, value ) {

*
* @param {WPElement} element Element to serialize.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {import('react').ReactNode} element Element to serialize.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -380,3 +382,6 @@ * @return {string} Serialized element.

const { type, props } = element;
const {
type,
props,
} = /** @type {{type?: any, props?: any}} */ ( element );

@@ -446,7 +451,7 @@ switch ( type ) {

*
* @param {?string} type Native component type to serialize, or null if
* rendering as fragment of children content.
* @param {Object} props Props object.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {?string} type Native component type to serialize, or null if
* rendering as fragment of children content.
* @param {Object} props Props object.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -491,9 +496,11 @@ * @return {string} Serialized element.

/** @typedef {import('./react').WPComponent} WPComponent */
/**
* Serializes a non-native component type to string.
*
* @param {Function} Component Component type to serialize.
* @param {Object} props Props object.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {WPComponent} Component Component type to serialize.
* @param {Object} props Props object.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -508,6 +515,18 @@ * @return {string} Serialized element

) {
const instance = new Component( props, legacyContext );
const instance = new /** @type {import('react').ComponentClass} */ ( Component )(
props,
legacyContext
);
if ( typeof instance.getChildContext === 'function' ) {
Object.assign( legacyContext, instance.getChildContext() );
if (
typeof (
// Ignore reason: Current prettier reformats parens and mangles type assertion
// prettier-ignore
/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext
) === 'function'
) {
Object.assign(
legacyContext,
/** @type {{getChildContext?: () => unknown}} */ ( instance ).getChildContext()
);
}

@@ -523,5 +542,5 @@

*
* @param {Array} children Children to serialize.
* @param {?Object} context Context object.
* @param {?Object} legacyContext Legacy context object.
* @param {import('react').ReactNodeArray} children Children to serialize.
* @param {Object} [context] Context object.
* @param {Object} [legacyContext] Legacy context object.
*

@@ -528,0 +547,0 @@ * @return {string} Serialized children.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc