@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.mjs CHANGED
@@ -1858,8 +1858,15 @@ var audit2 = {
1858
1858
  };
1859
1859
 
1860
1860
  // src/audits/deep-nesting.ts
1861
+ import { getWidgetsCache } from "@elementor/editor-elements";
1861
1862
  import { __ as __25 } from "@wordpress/i18n";
1862
1863
  var MAX_NESTING_DEPTH = 6;
1864
+ function isNestingElement(node, widgetsCache) {
1865
+ if (node.elType === "container") {
1866
+ return true;
1867
+ }
1868
+ return !!widgetsCache?.[node.elType]?.meta?.is_container;
1869
+ }
1863
1870
  var audit3 = {
1864
1871
  id: "audits/deep-nesting",
1865
1872
  title: __25("Deep container nesting", "elementor"),
@@ -1875,12 +1882,13 @@ var audit3 = {
1875
1882
  if (ctx.elements.tree.length === 0) {
1876
1883
  return { status: "skipped", reason: __25("No elements", "elementor") };
1877
1884
  }
1885
+ const widgetsCache = getWidgetsCache();
1878
1886
  const violations = [];
1879
1887
  walkElements(ctx.elements.tree, (node, parents) => {
1880
- if (node.elType !== "container") {
1888
+ if (!isNestingElement(node, widgetsCache)) {
1881
1889
  return;
1882
1890
  }
1883
- const depth = parents.length + 1;
1891
+ const depth = parents.filter((parent) => isNestingElement(parent, widgetsCache)).length + 1;
1884
1892
  if (depth > MAX_NESTING_DEPTH) {
1885
1893
  violations.push({
1886
1894
  auditId: audit3.id,
@@ -1925,7 +1933,7 @@ var audit4 = {
1925
1933
  };
1926
1934
 
1927
1935
  // src/audits/deprecated-widgets.ts
1928
- import { getWidgetsCache } from "@elementor/editor-elements";
1936
+ import { getWidgetsCache as getWidgetsCache2 } from "@elementor/editor-elements";
1929
1937
  import { __ as __27 } from "@wordpress/i18n";
1930
1938
  var DEPRECATION_CONTROL_NAME = "deprecation_message";
1931
1939
  var audit5 = {
@@ -1940,7 +1948,7 @@ var audit5 = {
1940
1948
  severity: "warning",
1941
1949
  weight: 7,
1942
1950
  evaluate: (ctx) => {
1943
- const widgetsCache = getWidgetsCache();
1951
+ const widgetsCache = getWidgetsCache2();
1944
1952
  if (!widgetsCache) {
1945
1953
  return { status: "skipped", reason: "widgets-cache-unavailable" };
1946
1954
  }
@@ -2950,8 +2958,15 @@ var audit21 = {
2950
2958
  };
2951
2959
 
2952
2960
  // src/audits/too-many-widgets.ts
2961
+ import { getWidgetsCache as getWidgetsCache3 } from "@elementor/editor-elements";
2953
2962
  import { __ as __44 } from "@wordpress/i18n";
2954
2963
  var WIDGET_COUNT_THRESHOLD = 100;
2964
+ function isCountableWidget(node, widgetsCache) {
2965
+ if (node.elType === "widget") {
2966
+ return true;
2967
+ }
2968
+ return !!widgetsCache?.[node.elType]?.meta?.is_compound;
2969
+ }
2955
2970
  var audit22 = {
2956
2971
  id: "audits/too-many-widgets",
2957
2972
  title: __44("Too many widgets", "elementor"),
@@ -2964,9 +2979,10 @@ var audit22 = {
2964
2979
  if (ctx.elements.tree.length === 0) {
2965
2980
  return { status: "skipped", reason: __44("No elements", "elementor") };
2966
2981
  }
2982
+ const widgetsCache = getWidgetsCache3();
2967
2983
  let widgetCount = 0;
2968
2984
  walkElements(ctx.elements.tree, (node) => {
2969
- if (node.elType === "widget") {
2985
+ if (isCountableWidget(node, widgetsCache)) {
2970
2986
  widgetCount++;
2971
2987
  }
2972
2988
  });