@elementor/editor-audits 4.4.0-1129 → 4.4.0-1131

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-audits",
3
- "version": "4.4.0-1129",
3
+ "version": "4.4.0-1131",
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-1129",
43
- "@elementor/editor-mcp": "4.4.0-1129",
44
- "@elementor/editor-app-bar": "4.4.0-1129",
45
- "@elementor/editor-elements": "4.4.0-1129",
46
- "@elementor/editor-floating-panels": "4.4.0-1129",
47
- "@elementor/editor-notifications": "4.4.0-1129",
48
- "@elementor/editor-props": "4.4.0-1129",
49
- "@elementor/editor-styles": "4.4.0-1129",
50
- "@elementor/editor-v1-adapters": "4.4.0-1129",
51
- "@elementor/events": "4.4.0-1129",
52
- "@elementor/http-client": "4.4.0-1129",
42
+ "@elementor/editor": "4.4.0-1131",
43
+ "@elementor/editor-mcp": "4.4.0-1131",
44
+ "@elementor/editor-app-bar": "4.4.0-1131",
45
+ "@elementor/editor-elements": "4.4.0-1131",
46
+ "@elementor/editor-floating-panels": "4.4.0-1131",
47
+ "@elementor/editor-notifications": "4.4.0-1131",
48
+ "@elementor/editor-props": "4.4.0-1131",
49
+ "@elementor/editor-styles": "4.4.0-1131",
50
+ "@elementor/editor-v1-adapters": "4.4.0-1131",
51
+ "@elementor/events": "4.4.0-1131",
52
+ "@elementor/http-client": "4.4.0-1131",
53
53
  "@elementor/icons": "~1.78.1",
54
- "@elementor/locations": "4.4.0-1129",
55
- "@elementor/session": "4.4.0-1129",
56
- "@elementor/store": "4.4.0-1129",
54
+ "@elementor/locations": "4.4.0-1131",
55
+ "@elementor/session": "4.4.0-1131",
56
+ "@elementor/store": "4.4.0-1131",
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 ( ! hasPageImages( ctx.elements.tree ) ) {
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
- walkImageLikeSources( ctx.elements.tree, ( { node, media } ) => {
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 { walkAtomicBackgroundImageSources } from '../utils/atomic-background-image-sources';
5
- import { walkAtomicImageSources } from '../utils/atomic-image-sources';
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
- walkImageLikeSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
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 { walkAtomicBackgroundImageSources } from '../utils/atomic-background-image-sources';
5
- import { walkAtomicImageSources } from '../utils/atomic-image-sources';
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
- walkImageLikeSources( ctx.elements.tree, ( { node, media } ) => evaluateSource( node, media ) );
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' ) };
@@ -33,7 +33,7 @@ function SeverityCard( { severity, count }: SeverityCardProps ) {
33
33
  flex={ 1 }
34
34
  flexDirection="column"
35
35
  gap={ 1 }
36
- bgcolor="grey.50"
36
+ bgcolor="action.hover"
37
37
  borderRadius={ 1.5 }
38
38
  px={ 1.5 }
39
39
  py={ 1 }
@@ -22,7 +22,6 @@ import * as robotsNoindex from './audits/robots-noindex';
22
22
  import * as scanForCookies from './audits/scan-for-cookies';
23
23
  import * as sectionsAndColumns from './audits/sections-and-columns';
24
24
  import * as siteIdentity from './audits/site-identity';
25
- import * as tooManyWidgets from './audits/too-many-widgets';
26
25
  import { registerAudit } from './registry';
27
26
  import { type Audit } from './types';
28
27
 
@@ -33,7 +32,6 @@ const AUDITS: Audit[] = [
33
32
 
34
33
  hiddenElements.audit,
35
34
  deprecatedWidgets.audit,
36
- tooManyWidgets.audit,
37
35
  sectionsAndColumns.audit,
38
36
  deepNesting.audit,
39
37
  nestedBoxedContainers.audit,
@@ -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 ATOMIC_IMAGE_PROP_KEYS = [ 'image', 'poster' ] as 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 ATOMIC_IMAGE_PROP_KEYS ) {
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 { 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';
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
- const collect = ( media: ImageLikeMedia ) => {
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
  }
@@ -1,53 +0,0 @@
1
- import { getWidgetsCache } from '@elementor/editor-elements';
2
- import { __ } from '@wordpress/i18n';
3
-
4
- import { type Audit, type ElementSnapshotNode } from '../types';
5
- import { walkElements } from '../utils/walk';
6
-
7
- const WIDGET_COUNT_THRESHOLD = 100;
8
-
9
- function isCountableWidget( node: ElementSnapshotNode, widgetsCache: ReturnType< typeof getWidgetsCache > ): boolean {
10
- if ( node.elType === 'widget' ) {
11
- return true;
12
- }
13
-
14
- return !! widgetsCache?.[ node.elType ]?.meta?.is_compound;
15
- }
16
-
17
- export const audit: Audit = {
18
- id: 'audits/too-many-widgets',
19
- title: __( 'Too many widgets', 'elementor' ),
20
- description: __( 'Excessive DOM size caused by too many widgets degrades rendering performance.', 'elementor' ),
21
- fixHint: __( 'Reduce the number of widgets on the page by removing or combining elements.', 'elementor' ),
22
- categories: [ 'best-practices', 'performance' ],
23
- severity: 'warning',
24
- weight: 5,
25
- evaluate: ( ctx ) => {
26
- if ( ctx.elements.tree.length === 0 ) {
27
- return { status: 'skipped', reason: __( 'No elements', 'elementor' ) };
28
- }
29
-
30
- const widgetsCache = getWidgetsCache();
31
- let widgetCount = 0;
32
-
33
- walkElements( ctx.elements.tree, ( node ) => {
34
- if ( isCountableWidget( node, widgetsCache ) ) {
35
- widgetCount++;
36
- }
37
- } );
38
-
39
- if ( widgetCount <= WIDGET_COUNT_THRESHOLD ) {
40
- return { status: 'pass' };
41
- }
42
-
43
- return {
44
- status: 'fail',
45
- violations: [
46
- {
47
- auditId: audit.id,
48
- label: __( 'Page has too many widgets.', 'elementor' ),
49
- },
50
- ],
51
- };
52
- },
53
- };