• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 2933c98962a853be2048beeb812f0fac9b2a8197

15 Jan 2026 04:12PM UTC coverage: 53.19% (+0.4%) from 52.832%
2933c98962a853be2048beeb812f0fac9b2a8197

Pull #22887

github

web-flow
Merge edcd36026 into d394743dd
Pull Request #22887: Add a new key for step attribute and adapt the relevant code and make…

8774 of 16370 branches covered (53.6%)

Branch coverage included in aggregate %.

5 of 135 new or added lines in 14 files covered. (3.7%)

42 existing lines in 4 files now uncovered.

32905 of 61988 relevant lines covered (53.08%)

46516.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/js/src/structured-data-blocks/shared-utils/migrationHelpers269.js
1
import { renderToString } from "@wordpress/element";
2

3
/**
4
 * Converts a rich text children array to an HTML string.
5
 *
6
 * @param {Array|string} value The value to convert.
7
 * @returns {string} The HTML string.
8
 */
NEW
9
export const childrenToString = ( value ) => {
×
NEW
10
        if ( ! value ) {
×
NEW
11
                return "";
×
12
        }
NEW
13
        if ( typeof value === "string" ) {
×
NEW
14
                return value;
×
15
        }
NEW
16
        if ( Array.isArray( value ) ) {
×
NEW
17
                try {
×
NEW
18
                        return renderToString( value );
×
19
                } catch ( e ) {
20
                        // Fallback: join string parts.
NEW
21
                        return value
×
22
                                .map( ( item ) => {
NEW
23
                                        if ( typeof item === "string" ) {
×
NEW
24
                                                return item;
×
25
                                        }
NEW
26
                                        if ( item && item.props ) {
×
NEW
27
                                                return renderToString( item );
×
28
                                        }
NEW
29
                                        return "";
×
30
                                } )
31
                                .join( "" );
32
                }
33
        }
NEW
34
        return "";
×
35
};
36

37
/**
38
 * Builds an image object from a node.
39
 * @param {object} node The image node.
40
 * @returns {{type: string, key: null, props: {src: string, alt: string, className: string, style: string}}} The image object.
41
 */
NEW
42
const buildImageObject = ( node ) => {
×
NEW
43
        const { key, props = {} } = node;
×
NEW
44
        const { src = "", alt = "", className = "", style = "" } = props;
×
45

NEW
46
        return {
×
47
                type: "img",
48
                key,
49
                props: { src, alt, className, style },
50
        };
51
};
52

53
/**
54
 * Extracts image elements from an old array-based text field.
55
 *
56
 * @param {Array} textArray The old text array that may contain image elements.
57
 * @returns {Array} Array of image objects in the new format.
58
 */
NEW
59
const extractImagesFromTextArray = ( textArray ) => {
×
NEW
60
        if ( ! Array.isArray( textArray ) ) {
×
NEW
61
                return [];
×
62
        }
63

NEW
64
        return textArray
×
NEW
65
                .filter( ( node ) => node && node.type && node.type === "img" )
×
66
                .map( buildImageObject );
67
};
68

69

70
/**
71
 * Gets the image array for a step, extracting from text if necessary.
72
 * @param {object[]} imageArray The existing images array.
73
 * @param {Array|string} content The text content to extract images from if needed.
74
 * @returns {object[]} The image array.
75
 */
NEW
76
export const getImageArray = ( imageArray, content ) => {
×
NEW
77
        if ( Array.isArray( content ) && imageArray.length === 0 ) {
×
NEW
78
                imageArray = extractImagesFromTextArray( content );
×
79
        }
NEW
80
        return imageArray;
×
81
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc