@elementor/editor-audits 4.4.0-1100 → 4.4.0-1101
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 +21 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/audits/deep-nesting.ts +13 -3
- package/src/audits/too-many-widgets.ts +12 -2
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-1101",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,19 +39,19 @@
|
|
|
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-v1-adapters": "4.4.0-
|
|
49
|
-
"@elementor/events": "4.4.0-
|
|
50
|
-
"@elementor/http-client": "4.4.0-
|
|
42
|
+
"@elementor/editor": "4.4.0-1101",
|
|
43
|
+
"@elementor/editor-mcp": "4.4.0-1101",
|
|
44
|
+
"@elementor/editor-app-bar": "4.4.0-1101",
|
|
45
|
+
"@elementor/editor-elements": "4.4.0-1101",
|
|
46
|
+
"@elementor/editor-floating-panels": "4.4.0-1101",
|
|
47
|
+
"@elementor/editor-notifications": "4.4.0-1101",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.4.0-1101",
|
|
49
|
+
"@elementor/events": "4.4.0-1101",
|
|
50
|
+
"@elementor/http-client": "4.4.0-1101",
|
|
51
51
|
"@elementor/icons": "~1.77.0",
|
|
52
|
-
"@elementor/locations": "4.4.0-
|
|
53
|
-
"@elementor/session": "4.4.0-
|
|
54
|
-
"@elementor/store": "4.4.0-
|
|
52
|
+
"@elementor/locations": "4.4.0-1101",
|
|
53
|
+
"@elementor/session": "4.4.0-1101",
|
|
54
|
+
"@elementor/store": "4.4.0-1101",
|
|
55
55
|
"@elementor/ui": "1.37.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { getWidgetsCache } from '@elementor/editor-elements';
|
|
1
2
|
import { __ } from '@wordpress/i18n';
|
|
2
3
|
|
|
3
|
-
import { type Audit, type AuditViolation } from '../types';
|
|
4
|
+
import { type Audit, type AuditViolation, type ElementSnapshotNode } from '../types';
|
|
4
5
|
import { walkElements } from '../utils/walk';
|
|
5
6
|
|
|
6
7
|
const MAX_NESTING_DEPTH = 6;
|
|
7
8
|
|
|
9
|
+
function isNestingElement( node: ElementSnapshotNode, widgetsCache: ReturnType< typeof getWidgetsCache > ): boolean {
|
|
10
|
+
if ( node.elType === 'container' ) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return !! widgetsCache?.[ node.elType ]?.meta?.is_container;
|
|
15
|
+
}
|
|
16
|
+
|
|
8
17
|
export const audit: Audit = {
|
|
9
18
|
id: 'audits/deep-nesting',
|
|
10
19
|
title: __( 'Deep container nesting', 'elementor' ),
|
|
@@ -21,14 +30,15 @@ export const audit: Audit = {
|
|
|
21
30
|
return { status: 'skipped', reason: __( 'No elements', 'elementor' ) };
|
|
22
31
|
}
|
|
23
32
|
|
|
33
|
+
const widgetsCache = getWidgetsCache();
|
|
24
34
|
const violations: AuditViolation[] = [];
|
|
25
35
|
|
|
26
36
|
walkElements( ctx.elements.tree, ( node, parents ) => {
|
|
27
|
-
if ( node
|
|
37
|
+
if ( ! isNestingElement( node, widgetsCache ) ) {
|
|
28
38
|
return;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
|
-
const depth = parents.length + 1;
|
|
41
|
+
const depth = parents.filter( ( parent ) => isNestingElement( parent, widgetsCache ) ).length + 1;
|
|
32
42
|
|
|
33
43
|
if ( depth > MAX_NESTING_DEPTH ) {
|
|
34
44
|
violations.push( {
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { getWidgetsCache } from '@elementor/editor-elements';
|
|
1
2
|
import { __ } from '@wordpress/i18n';
|
|
2
3
|
|
|
3
|
-
import { type Audit } from '../types';
|
|
4
|
+
import { type Audit, type ElementSnapshotNode } from '../types';
|
|
4
5
|
import { walkElements } from '../utils/walk';
|
|
5
6
|
|
|
6
7
|
const WIDGET_COUNT_THRESHOLD = 100;
|
|
7
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
|
+
|
|
8
17
|
export const audit: Audit = {
|
|
9
18
|
id: 'audits/too-many-widgets',
|
|
10
19
|
title: __( 'Too many widgets', 'elementor' ),
|
|
@@ -18,10 +27,11 @@ export const audit: Audit = {
|
|
|
18
27
|
return { status: 'skipped', reason: __( 'No elements', 'elementor' ) };
|
|
19
28
|
}
|
|
20
29
|
|
|
30
|
+
const widgetsCache = getWidgetsCache();
|
|
21
31
|
let widgetCount = 0;
|
|
22
32
|
|
|
23
33
|
walkElements( ctx.elements.tree, ( node ) => {
|
|
24
|
-
if ( node
|
|
34
|
+
if ( isCountableWidget( node, widgetsCache ) ) {
|
|
25
35
|
widgetCount++;
|
|
26
36
|
}
|
|
27
37
|
} );
|