: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @return {string} String HTML representation of block node.
function children_toHTML(children) {
external_wp_deprecated_default()('wp.blocks.children.toHTML', {
alternative: 'wp.richText.toHTMLString',
link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
const element = getSerializeCapableElement(children);
return (0,external_wp_element_namespaceObject.renderToString)(element);
* Given a selector, returns an hpq matcher generating a WPBlockChildren value
* matching the selector result.
* @param {string} selector DOM selector.
* @return {Function} hpq matcher.
function children_matcher(selector) {
external_wp_deprecated_default()('wp.blocks.children.matcher', {
alternative: 'html source',
link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
match = domNode.querySelector(selector);
return children_fromDOM(match.childNodes);
* Object of utility functions used in managing block attribute values of
* @see https://github.com/WordPress/gutenberg/pull/10439
* @deprecated since 4.0. The `children` source should not be used, and can be
* replaced by the `html` source.
/* harmony default export */ const children = ({
fromDOM: children_fromDOM,
matcher: children_matcher
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/get-block-attributes.js
* Higher-order hpq matcher which enhances an attribute matcher to return true
* or false depending on whether the original matcher returns undefined. This
* is useful for boolean attributes (e.g. disabled) whose attribute values may
* be technically falsey (empty string), though their mere presence should be
* enough to infer as true.
* @param {Function} matcher Original hpq matcher.
* @return {Function} Enhanced hpq matcher.
const toBooleanAttributeMatcher = matcher => value => matcher(value) !== undefined;
* Returns true if value is of the given JSON schema type, or false otherwise.
* @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
* @param {*} value Value to test.
* @param {string} type Type to test.
* @return {boolean} Whether value is of type.
function isOfType(value, type) {
return value instanceof external_wp_richText_namespaceObject.RichTextData;
return typeof value === 'string';
return typeof value === 'boolean';
return !!value && value.constructor === Object;
return Array.isArray(value);
return typeof value === 'number';
* Returns true if value is of an array of given JSON schema types, or false
* @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
* @param {*} value Value to test.
* @param {string[]} types Types to test.
* @return {boolean} Whether value is of types.
function isOfTypes(value, types) {
return types.some(type => isOfType(value, type));
* Given an attribute key, an attribute's schema, a block's raw content and the
* commentAttributes returns the attribute value depending on its source
* definition of the given attribute key.
* @param {string} attributeKey Attribute key.
* @param {Object} attributeSchema Attribute's schema.
* @param {Node} innerDOM Parsed DOM of block's inner HTML.
* @param {Object} commentAttributes Block's comment attributes.
* @param {string} innerHTML Raw HTML from block node's innerHTML property.
* @return {*} Attribute value.
function getBlockAttribute(attributeKey, attributeSchema, innerDOM, commentAttributes, innerHTML) {
switch (attributeSchema.source) {
// An undefined source means that it's an attribute serialized to the
value = commentAttributes ? commentAttributes[attributeKey] : undefined;
// raw source means that it's the original raw block content.
value = parseWithAttributeSchema(innerDOM, attributeSchema);
if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) {
// Reject the value if it is not valid. Reverting to the undefined
// value ensures the default is respected, if applicable.
if (value === undefined) {
value = getDefault(attributeSchema);
* Returns true if value is valid per the given block attribute schema type
* definition, or false otherwise.
* @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1
* @param {*} value Value to test.
* @param {?(Array<string>|string)} type Block attribute schema type.
* @return {boolean} Whether value is valid.
function isValidByType(value, type) {
return type === undefined || isOfTypes(value, Array.isArray(type) ? type : [type]);
* Returns true if value is valid per the given block attribute schema enum
* definition, or false otherwise.
* @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2
* @param {*} value Value to test.
* @param {?Array} enumSet Block attribute schema enum.
* @return {boolean} Whether value is valid.
function isValidByEnum(value, enumSet) {
return !Array.isArray(enumSet) || enumSet.includes(value);
* Returns an hpq matcher given a source object.
* @param {Object} sourceConfig Attribute Source object.
* @return {Function} A hpq Matcher.
const matcherFromSource = memize(sourceConfig => {
switch (sourceConfig.source) {
let matcher = attr(sourceConfig.selector, sourceConfig.attribute);
if (sourceConfig.type === 'boolean') {
matcher = toBooleanAttributeMatcher(matcher);
return matchers_html(sourceConfig.selector, sourceConfig.multiline);
return es_text(sourceConfig.selector);
return richText(sourceConfig.selector, sourceConfig.__unstablePreserveWhiteSpace);
return children_matcher(sourceConfig.selector);
return matcher(sourceConfig.selector);
const subMatchers = Object.fromEntries(Object.entries(sourceConfig.query).map(([key, subSourceConfig]) => [key, matcherFromSource(subSourceConfig)]));
return query(sourceConfig.selector, subMatchers);
const matcher = prop(sourceConfig.selector, 'nodeName');
return domNode => matcher(domNode)?.toLowerCase();
// eslint-disable-next-line no-console
console.error(`Unknown source type "${sourceConfig.source}"`);
* Parse a HTML string into DOM tree.
* @param {string|Node} innerHTML HTML string or already parsed DOM node.
* @return {Node} Parsed DOM node.
function parseHtml(innerHTML) {
return parse(innerHTML, h => h);
* Given a block's raw content and an attribute's schema returns the attribute's
* value depending on its source.
* @param {string|Node} innerHTML Block's raw content.
* @param {Object} attributeSchema Attribute's schema.
* @return {*} Attribute value.
function parseWithAttributeSchema(innerHTML, attributeSchema) {
return matcherFromSource(attributeSchema)(parseHtml(innerHTML));
* Returns the block attributes of a registered block node given its type.
* @param {string|Object} blockTypeOrName Block type or name.
* @param {string|Node} innerHTML Raw block content.
* @param {?Object} attributes Known block attributes (from delimiters).
* @return {Object} All block attributes.
function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) {
var _blockType$attributes;
const doc = parseHtml(innerHTML);
const blockType = normalizeBlockType(blockTypeOrName);
const blockAttributes = Object.fromEntries(Object.entries((_blockType$attributes = blockType.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}).map(([key, schema]) => [key, getBlockAttribute(key, schema, doc, attributes, innerHTML)]));
return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/fix-custom-classname.js
const CLASS_ATTR_SCHEMA = {
selector: '[data-custom-class-name] > *',
* Given an HTML string, returns an array of class names assigned to the root
* @param {string} innerHTML Markup string from which to extract classes.
* @return {string[]} Array of class names assigned to the root element.
function getHTMLRootElementClasses(innerHTML) {
const parsed = parseWithAttributeSchema(`<div data-custom-class-name>${innerHTML}</div>`, CLASS_ATTR_SCHEMA);
return parsed ? parsed.trim().split(/\s+/) : [];
* Given a parsed set of block attributes, if the block supports custom class
* names and an unknown class (per the block's serialization behavior) is
* found, the unknown classes are treated as custom classes. This prevents the
* block from being considered as invalid.
* @param {Object} blockAttributes Original block attributes.
* @param {Object} blockType Block type settings.
* @param {string} innerHTML Original block markup.
* @return {Object} Filtered block attributes.
function fixCustomClassname(blockAttributes, blockType, innerHTML) {
if (hasBlockSupport(blockType, 'customClassName', true)) {
// To determine difference, serialize block given the known set of
// attributes, with the exception of `className`. This will determine
// the default set of classes. From there, any difference in innerHTML
// can be considered as custom classes.
className: omittedClassName,
...attributesSansClassName
const serialized = getSaveContent(blockType, attributesSansClassName);
const defaultClasses = getHTMLRootElementClasses(serialized);
const actualClasses = getHTMLRootElementClasses(innerHTML);
const customClasses = actualClasses.filter(className => !defaultClasses.includes(className));
if (customClasses.length) {
blockAttributes.className = customClasses.join(' ');
delete blockAttributes.className;
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-built-in-validation-fixes.js
* Attempts to fix block invalidation by applying build-in validation fixes
* like moving all extra classNames to the className attribute.
* @param {WPBlock} block block object.
* @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and
* can be inferred from the block name,
* but it's here for performance reasons.
* @return {WPBlock} Fixed block object
function applyBuiltInValidationFixes(block, blockType) {
const updatedBlockAttributes = fixCustomClassname(block.attributes, blockType, block.originalContent);
attributes: updatedBlockAttributes
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-block-deprecated-versions.js
* Function that takes no arguments and always returns false.
* @return {boolean} Always returns false.
* Given a block object, returns a new copy of the block with any applicable
* deprecated migrations applied, or the original block if it was both valid
* and no eligible migrations exist.
* @param {import(".").WPBlock} block Parsed and invalid block object.
* @param {import(".").WPRawBlock} rawBlock Raw block object.
* @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and
* can be inferred from the block name,
* but it's here for performance reasons.
* @return {import(".").WPBlock} Migrated block object.
function applyBlockDeprecatedVersions(block, rawBlock, blockType) {
const parsedAttributes = rawBlock.attrs;
deprecated: deprecatedDefinitions
// Bail early if there are no registered deprecations to be handled.
if (!deprecatedDefinitions || !deprecatedDefinitions.length) {
// By design, blocks lack any sort of version tracking. Instead, to process
// outdated content the system operates a queue out of all the defined
// attribute shapes and tries each definition until the input produces a
// valid result. This mechanism seeks to avoid polluting the user-space with
// machine-specific code. An invalid block is thus a block that could not be
// matched successfully with any of the registered deprecation definitions.
for (let i = 0; i < deprecatedDefinitions.length; i++) {
// A block can opt into a migration even if the block is valid by
// defining `isEligible` on its deprecation. If the block is both valid
// and does not opt to migrate, skip.
} = deprecatedDefinitions[i];
if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks, {
// Block type properties which could impact either serialization or
// parsing are not considered in the deprecated block type by default,
// and must be explicitly provided.
const deprecatedBlockType = Object.assign(omit(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]);
attributes: getBlockAttributes(deprecatedBlockType, block.originalContent, parsedAttributes)
// Ignore the deprecation if it produces a block which is not valid.
let [isValid] = validateBlock(migratedBlock, deprecatedBlockType);
// If the migrated block is not valid initially, try the built-in fixes.
migratedBlock = applyBuiltInValidationFixes(migratedBlock, deprecatedBlockType);
[isValid] = validateBlock(migratedBlock, deprecatedBlockType);
// An invalid block does not imply incorrect HTML but the fact block
// source information could be lost on re-serialization.
let migratedInnerBlocks = migratedBlock.innerBlocks;
let migratedAttributes = migratedBlock.attributes;
// A block may provide custom behavior to assign new attributes and/or
let migrated = migrate(migratedAttributes, block.innerBlocks);
if (!Array.isArray(migrated)) {
[migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = migrated;
attributes: migratedAttributes,
innerBlocks: migratedInnerBlocks,
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/index.js