@wordpress/blocks
Version:
Block API for WordPress.
40 lines (37 loc) • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.applyBuiltInValidationFixes = applyBuiltInValidationFixes;
var _fixCustomClassname = require("./fix-custom-classname");
var _fixAriaLabel = require("./fix-aria-label");
/**
* Internal dependencies
*/
/**
* 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 {
attributes,
originalContent
} = block;
let updatedBlockAttributes = attributes;
// Fix block invalidation for className attribute.
updatedBlockAttributes = (0, _fixCustomClassname.fixCustomClassname)(attributes, blockType, originalContent);
// Fix block invalidation for ariaLabel attribute.
updatedBlockAttributes = (0, _fixAriaLabel.fixAriaLabel)(updatedBlockAttributes, blockType, originalContent);
return {
...block,
attributes: updatedBlockAttributes
};
}
//# sourceMappingURL=apply-built-in-validation-fixes.js.map