@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 CHANGED
@@ -1878,8 +1878,15 @@ var audit2 = {
1878
1878
  };
1879
1879
 
1880
1880
  // src/audits/deep-nesting.ts
1881
+ var import_editor_elements6 = require("@elementor/editor-elements");
1881
1882
  var import_i18n25 = require("@wordpress/i18n");
1882
1883
  var MAX_NESTING_DEPTH = 6;
1884
+ function isNestingElement(node, widgetsCache) {
1885
+ if (node.elType === "container") {
1886
+ return true;
1887
+ }
1888
+ return !!widgetsCache?.[node.elType]?.meta?.is_container;
1889
+ }
1883
1890
  var audit3 = {
1884
1891
  id: "audits/deep-nesting",
1885
1892
  title: (0, import_i18n25.__)("Deep container nesting", "elementor"),
@@ -1895,12 +1902,13 @@ var audit3 = {
1895
1902
  if (ctx.elements.tree.length === 0) {
1896
1903
  return { status: "skipped", reason: (0, import_i18n25.__)("No elements", "elementor") };
1897
1904
  }
1905
+ const widgetsCache = (0, import_editor_elements6.getWidgetsCache)();
1898
1906
  const violations = [];
1899
1907
  walkElements(ctx.elements.tree, (node, parents) => {
1900
- if (node.elType !== "container") {
1908
+ if (!isNestingElement(node, widgetsCache)) {
1901
1909
  return;
1902
1910
  }
1903
- const depth = parents.length + 1;
1911
+ const depth = parents.filter((parent) => isNestingElement(parent, widgetsCache)).length + 1;
1904
1912
  if (depth > MAX_NESTING_DEPTH) {
1905
1913
  violations.push({
1906
1914
  auditId: audit3.id,
@@ -1945,7 +1953,7 @@ var audit4 = {
1945
1953
  };
1946
1954
 
1947
1955
  // src/audits/deprecated-widgets.ts
1948
- var import_editor_elements6 = require("@elementor/editor-elements");
1956
+ var import_editor_elements7 = require("@elementor/editor-elements");
1949
1957
  var import_i18n27 = require("@wordpress/i18n");
1950
1958
  var DEPRECATION_CONTROL_NAME = "deprecation_message";
1951
1959
  var audit5 = {
@@ -1960,7 +1968,7 @@ var audit5 = {
1960
1968
  severity: "warning",
1961
1969
  weight: 7,
1962
1970
  evaluate: (ctx) => {
1963
- const widgetsCache = (0, import_editor_elements6.getWidgetsCache)();
1971
+ const widgetsCache = (0, import_editor_elements7.getWidgetsCache)();
1964
1972
  if (!widgetsCache) {
1965
1973
  return { status: "skipped", reason: "widgets-cache-unavailable" };
1966
1974
  }
@@ -2970,8 +2978,15 @@ var audit21 = {
2970
2978
  };
2971
2979
 
2972
2980
  // src/audits/too-many-widgets.ts
2981
+ var import_editor_elements8 = require("@elementor/editor-elements");
2973
2982
  var import_i18n44 = require("@wordpress/i18n");
2974
2983
  var WIDGET_COUNT_THRESHOLD = 100;
2984
+ function isCountableWidget(node, widgetsCache) {
2985
+ if (node.elType === "widget") {
2986
+ return true;
2987
+ }
2988
+ return !!widgetsCache?.[node.elType]?.meta?.is_compound;
2989
+ }
2975
2990
  var audit22 = {
2976
2991
  id: "audits/too-many-widgets",
2977
2992
  title: (0, import_i18n44.__)("Too many widgets", "elementor"),
@@ -2984,9 +2999,10 @@ var audit22 = {
2984
2999
  if (ctx.elements.tree.length === 0) {
2985
3000
  return { status: "skipped", reason: (0, import_i18n44.__)("No elements", "elementor") };
2986
3001
  }
3002
+ const widgetsCache = (0, import_editor_elements8.getWidgetsCache)();
2987
3003
  let widgetCount = 0;
2988
3004
  walkElements(ctx.elements.tree, (node) => {
2989
- if (node.elType === "widget") {
3005
+ if (isCountableWidget(node, widgetsCache)) {
2990
3006
  widgetCount++;
2991
3007
  }
2992
3008
  });