@elementor/editor-audits 4.4.0-1130 → 4.4.0-1132
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/dist/index.js +35 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/audits/images-alt-text.ts +3 -3
- package/src/audits/images-inefficient-format.ts +3 -8
- package/src/audits/images-too-large.ts +3 -8
- package/src/utils/all-image-sources.ts +17 -0
- package/src/utils/alt-text-image-sources.ts +24 -0
- package/src/utils/atomic-image-sources.ts +8 -4
- package/src/utils/image-like-sources.ts +0 -12
- package/src/utils/page-attachments.ts +3 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-audits",
|
|
3
|
-
"version": "4.4.0-
|
|
3
|
+
"version": "4.4.0-1132",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "4.4.0-
|
|
43
|
-
"@elementor/editor-mcp": "4.4.0-
|
|
44
|
-
"@elementor/editor-app-bar": "4.4.0-
|
|
45
|
-
"@elementor/editor-elements": "4.4.0-
|
|
46
|
-
"@elementor/editor-floating-panels": "4.4.0-
|
|
47
|
-
"@elementor/editor-notifications": "4.4.0-
|
|
48
|
-
"@elementor/editor-props": "4.4.0-
|
|
49
|
-
"@elementor/editor-styles": "4.4.0-
|
|
50
|
-
"@elementor/editor-v1-adapters": "4.4.0-
|
|
51
|
-
"@elementor/events": "4.4.0-
|
|
52
|
-
"@elementor/http-client": "4.4.0-
|
|
42
|
+
"@elementor/editor": "4.4.0-1132",
|
|
43
|
+
"@elementor/editor-mcp": "4.4.0-1132",
|
|
44
|
+
"@elementor/editor-app-bar": "4.4.0-1132",
|
|
45
|
+
"@elementor/editor-elements": "4.4.0-1132",
|
|
46
|
+
"@elementor/editor-floating-panels": "4.4.0-1132",
|
|
47
|
+
"@elementor/editor-notifications": "4.4.0-1132",
|
|
48
|
+
"@elementor/editor-props": "4.4.0-1132",
|
|
49
|
+
"@elementor/editor-styles": "4.4.0-1132",
|
|
50
|
+
"@elementor/editor-v1-adapters": "4.4.0-1132",
|
|
51
|
+
"@elementor/events": "4.4.0-1132",
|
|
52
|
+
"@elementor/http-client": "4.4.0-1132",
|
|
53
53
|
"@elementor/icons": "~1.78.1",
|
|
54
|
-
"@elementor/locations": "4.4.0-
|
|
55
|
-
"@elementor/session": "4.4.0-
|
|
56
|
-
"@elementor/store": "4.4.0-
|
|
54
|
+
"@elementor/locations": "4.4.0-1132",
|
|
55
|
+
"@elementor/session": "4.4.0-1132",
|
|
56
|
+
"@elementor/store": "4.4.0-1132",
|
|
57
57
|
"@elementor/ui": "1.41.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
|
|
3
3
|
import { type Audit, type AuditViolation } from '../types';
|
|
4
|
+
import { hasAltTextImages, walkAltTextImageSources } from '../utils/alt-text-image-sources';
|
|
4
5
|
import { hasMeaningfulAlt, isImageSourcePresent } from '../utils/image-alt';
|
|
5
|
-
import { hasPageImages, walkImageLikeSources } from '../utils/image-like-sources';
|
|
6
6
|
|
|
7
7
|
export const audit: Audit = {
|
|
8
8
|
id: 'audits/images-alt-text',
|
|
@@ -13,7 +13,7 @@ export const audit: Audit = {
|
|
|
13
13
|
severity: 'error',
|
|
14
14
|
weight: 10,
|
|
15
15
|
evaluate: ( ctx ) => {
|
|
16
|
-
if ( !
|
|
16
|
+
if ( ! hasAltTextImages( ctx.elements.tree ) ) {
|
|
17
17
|
return { status: 'skipped', reason: __( 'No images', 'elementor' ) };
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -22,7 +22,7 @@ export const audit: Audit = {
|
|
|
22
22
|
const failedWidgetIds = new Set< string >();
|
|
23
23
|
let missingAltImageCount = 0;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
walkAltTextImageSources( ctx.elements.tree, ( { node, media } ) => {
|
|
26
26
|
if ( ! isImageSourcePresent( media ) || hasMeaningfulAlt( media, ctx.pageContext ) ) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
|
|
3
3
|
import { type Audit, type AuditViolation, type ElementSnapshotNode } from '../types';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { walkBackgroundImageSources } from '../utils/background-image-sources';
|
|
7
|
-
import { type ImageLikeMedia, walkImageLikeSources } from '../utils/image-like-sources';
|
|
4
|
+
import { walkAllImageSources } from '../utils/all-image-sources';
|
|
5
|
+
import { type ImageLikeMedia } from '../utils/image-like-sources';
|
|
8
6
|
import { buildImageSizeKey } from '../utils/image-size-key';
|
|
9
7
|
|
|
10
8
|
const LEGACY_RASTER_MIME_TYPES = new Set( [ 'image/jpeg', 'image/png', 'image/gif', 'image/bmp', 'image/tiff' ] );
|
|
@@ -44,10 +42,7 @@ export const audit: Audit = {
|
|
|
44
42
|
offendingElementIds.add( node.id );
|
|
45
43
|
};
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
walkBackgroundImageSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
|
|
49
|
-
walkAtomicImageSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
|
|
50
|
-
walkAtomicBackgroundImageSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
|
|
45
|
+
walkAllImageSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
|
|
51
46
|
|
|
52
47
|
if ( ! hasAnyImage ) {
|
|
53
48
|
return { status: 'skipped', reason: __( 'No images', 'elementor' ) };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { __, sprintf } from '@wordpress/i18n';
|
|
2
2
|
|
|
3
3
|
import { type Audit, type AuditViolation, type ElementSnapshotNode } from '../types';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { walkBackgroundImageSources } from '../utils/background-image-sources';
|
|
7
|
-
import { type ImageLikeMedia, walkImageLikeSources } from '../utils/image-like-sources';
|
|
4
|
+
import { walkAllImageSources } from '../utils/all-image-sources';
|
|
5
|
+
import { type ImageLikeMedia } from '../utils/image-like-sources';
|
|
8
6
|
import { buildImageSizeKey } from '../utils/image-size-key';
|
|
9
7
|
|
|
10
8
|
const SIZE_THRESHOLD_BYTES = 500 * 1024;
|
|
@@ -48,10 +46,7 @@ export const audit: Audit = {
|
|
|
48
46
|
widgetMaxKb.set( node.id, Math.max( currentMax, kb ) );
|
|
49
47
|
};
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
walkBackgroundImageSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
|
|
53
|
-
walkAtomicImageSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
|
|
54
|
-
walkAtomicBackgroundImageSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
|
|
49
|
+
walkAllImageSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
|
|
55
50
|
|
|
56
51
|
if ( ! hasAnyImage ) {
|
|
57
52
|
return { status: 'skipped', reason: __( 'No images', 'elementor' ) };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ElementSnapshotNode } from '../types';
|
|
2
|
+
import { walkAtomicBackgroundImageSources } from './atomic-background-image-sources';
|
|
3
|
+
import { walkAtomicImageSources } from './atomic-image-sources';
|
|
4
|
+
import { walkBackgroundImageSources } from './background-image-sources';
|
|
5
|
+
import { type ImageLikeMedia, walkImageLikeSources } from './image-like-sources';
|
|
6
|
+
|
|
7
|
+
export type ImageSourceVisit = {
|
|
8
|
+
node: ElementSnapshotNode;
|
|
9
|
+
media: ImageLikeMedia;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function walkAllImageSources( tree: ElementSnapshotNode[], visit: ( source: ImageSourceVisit ) => void ): void {
|
|
13
|
+
walkImageLikeSources( tree, visit );
|
|
14
|
+
walkBackgroundImageSources( tree, visit );
|
|
15
|
+
walkAtomicImageSources( tree, visit );
|
|
16
|
+
walkAtomicBackgroundImageSources( tree, visit );
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ElementSnapshotNode } from '../types';
|
|
2
|
+
import { type ImageSourceVisit } from './all-image-sources';
|
|
3
|
+
import { ATOMIC_CONTENT_IMAGE_PROP_KEYS, walkAtomicImageSources } from './atomic-image-sources';
|
|
4
|
+
import { walkImageLikeSources } from './image-like-sources';
|
|
5
|
+
|
|
6
|
+
export function walkAltTextImageSources(
|
|
7
|
+
tree: ElementSnapshotNode[],
|
|
8
|
+
visit: ( source: ImageSourceVisit ) => void
|
|
9
|
+
): void {
|
|
10
|
+
walkImageLikeSources( tree, visit );
|
|
11
|
+
walkAtomicImageSources( tree, visit, ATOMIC_CONTENT_IMAGE_PROP_KEYS );
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function hasAltTextImages( tree: ElementSnapshotNode[] ): boolean {
|
|
15
|
+
let found = false;
|
|
16
|
+
|
|
17
|
+
walkAltTextImageSources( tree, ( { media } ) => {
|
|
18
|
+
if ( media.id || media.url ) {
|
|
19
|
+
found = true;
|
|
20
|
+
}
|
|
21
|
+
} );
|
|
22
|
+
|
|
23
|
+
return found;
|
|
24
|
+
}
|
|
@@ -10,7 +10,9 @@ import { type ElementSnapshotNode } from '../types';
|
|
|
10
10
|
import { type ImageLikeMedia } from './image-like-sources';
|
|
11
11
|
import { walkElements } from './walk';
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
export const ATOMIC_CONTENT_IMAGE_PROP_KEYS = [ 'image' ] as const;
|
|
14
|
+
|
|
15
|
+
const ATOMIC_IMAGE_PROP_KEYS = [ ...ATOMIC_CONTENT_IMAGE_PROP_KEYS, 'poster' ] as const;
|
|
14
16
|
|
|
15
17
|
export type AtomicImageSourceVisit = {
|
|
16
18
|
node: ElementSnapshotNode;
|
|
@@ -19,14 +21,15 @@ export type AtomicImageSourceVisit = {
|
|
|
19
21
|
|
|
20
22
|
export function walkAtomicImageSources(
|
|
21
23
|
tree: ElementSnapshotNode[],
|
|
22
|
-
visit: ( source: AtomicImageSourceVisit ) => void
|
|
24
|
+
visit: ( source: AtomicImageSourceVisit ) => void,
|
|
25
|
+
propKeys: readonly string[] = ATOMIC_IMAGE_PROP_KEYS
|
|
23
26
|
): void {
|
|
24
27
|
walkElements( tree, ( node ) => {
|
|
25
28
|
if ( node.elType !== 'widget' ) {
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
for ( const key of
|
|
32
|
+
for ( const key of propKeys ) {
|
|
30
33
|
const media = extractAtomicImageMedia( node.settings[ key ] );
|
|
31
34
|
|
|
32
35
|
if ( media ) {
|
|
@@ -56,7 +59,8 @@ export function extractAtomicImageMedia( imageProp: unknown ): ImageLikeMedia |
|
|
|
56
59
|
return null;
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
const alt = stringPropTypeUtil.extract( src.alt ) ?? undefined;
|
|
59
63
|
const size = stringPropTypeUtil.extract( image.size ) ?? undefined;
|
|
60
64
|
|
|
61
|
-
return { id, url, size };
|
|
65
|
+
return { id, url, alt, size };
|
|
62
66
|
}
|
|
@@ -15,18 +15,6 @@ export type ImageLikeSourceVisit = {
|
|
|
15
15
|
media: ImageLikeMedia;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
export function hasPageImages( tree: ElementSnapshotNode[] ): boolean {
|
|
19
|
-
let found = false;
|
|
20
|
-
|
|
21
|
-
walkImageLikeSources( tree, ( { media } ) => {
|
|
22
|
-
if ( media.id || media.url ) {
|
|
23
|
-
found = true;
|
|
24
|
-
}
|
|
25
|
-
} );
|
|
26
|
-
|
|
27
|
-
return found;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
18
|
export function walkImageLikeSources(
|
|
31
19
|
tree: ElementSnapshotNode[],
|
|
32
20
|
visit: ( source: ImageLikeSourceVisit ) => void
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { type ElementSnapshotNode } from '../types';
|
|
2
|
-
import {
|
|
3
|
-
import { walkAtomicImageSources } from './atomic-image-sources';
|
|
4
|
-
import { walkBackgroundImageSources } from './background-image-sources';
|
|
5
|
-
import { type ImageLikeMedia, walkImageLikeSources } from './image-like-sources';
|
|
2
|
+
import { walkAllImageSources } from './all-image-sources';
|
|
6
3
|
import { buildImageSizeKey } from './image-size-key';
|
|
7
4
|
|
|
8
5
|
export function extractImageSizeRequests( tree: ElementSnapshotNode[] ): string[] {
|
|
9
6
|
const keys = new Set< string >();
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
walkAllImageSources( tree, ( { media } ) => {
|
|
12
9
|
if ( media.id ) {
|
|
13
10
|
keys.add( buildImageSizeKey( { id: media.id, size: media.size } ) );
|
|
14
11
|
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
walkImageLikeSources( tree, ( { media } ) => collect( media ) );
|
|
18
|
-
walkBackgroundImageSources( tree, ( { media } ) => collect( media ) );
|
|
19
|
-
walkAtomicImageSources( tree, ( { media } ) => collect( media ) );
|
|
20
|
-
walkAtomicBackgroundImageSources( tree, ( { media } ) => collect( media ) );
|
|
12
|
+
} );
|
|
21
13
|
|
|
22
14
|
return Array.from( keys ).sort();
|
|
23
15
|
}
|