@elementor/editor-audits 4.4.0-1130 → 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/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/dist/index.js
CHANGED
|
@@ -392,13 +392,14 @@ function recurse(nodes, parents, visit) {
|
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
// src/utils/atomic-image-sources.ts
|
|
395
|
-
var
|
|
396
|
-
|
|
395
|
+
var ATOMIC_CONTENT_IMAGE_PROP_KEYS = ["image"];
|
|
396
|
+
var ATOMIC_IMAGE_PROP_KEYS = [...ATOMIC_CONTENT_IMAGE_PROP_KEYS, "poster"];
|
|
397
|
+
function walkAtomicImageSources(tree, visit, propKeys = ATOMIC_IMAGE_PROP_KEYS) {
|
|
397
398
|
walkElements(tree, (node) => {
|
|
398
399
|
if (node.elType !== "widget") {
|
|
399
400
|
return;
|
|
400
401
|
}
|
|
401
|
-
for (const key of
|
|
402
|
+
for (const key of propKeys) {
|
|
402
403
|
const media = extractAtomicImageMedia(node.settings[key]);
|
|
403
404
|
if (media) {
|
|
404
405
|
visit({ node, media });
|
|
@@ -420,8 +421,9 @@ function extractAtomicImageMedia(imageProp) {
|
|
|
420
421
|
if (!id && !url) {
|
|
421
422
|
return null;
|
|
422
423
|
}
|
|
424
|
+
const alt = import_editor_props.stringPropTypeUtil.extract(src.alt) ?? void 0;
|
|
423
425
|
const size = import_editor_props.stringPropTypeUtil.extract(image.size) ?? void 0;
|
|
424
|
-
return { id, url, size };
|
|
426
|
+
return { id, url, alt, size };
|
|
425
427
|
}
|
|
426
428
|
|
|
427
429
|
// src/utils/atomic-background-image-sources.ts
|
|
@@ -476,15 +478,6 @@ function walkBackgroundImageSources(tree, visit) {
|
|
|
476
478
|
|
|
477
479
|
// src/utils/image-like-sources.ts
|
|
478
480
|
var IMAGE_LIKE_WIDGETS = /* @__PURE__ */ new Set(["image", "image-box", "image-carousel", "gallery", "image-gallery"]);
|
|
479
|
-
function hasPageImages(tree) {
|
|
480
|
-
let found = false;
|
|
481
|
-
walkImageLikeSources(tree, ({ media }) => {
|
|
482
|
-
if (media.id || media.url) {
|
|
483
|
-
found = true;
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
return found;
|
|
487
|
-
}
|
|
488
481
|
function walkImageLikeSources(tree, visit) {
|
|
489
482
|
walkElements(tree, (node) => {
|
|
490
483
|
if (node.elType !== "widget") {
|
|
@@ -516,6 +509,14 @@ function collectMediaFromNode(node) {
|
|
|
516
509
|
return sources;
|
|
517
510
|
}
|
|
518
511
|
|
|
512
|
+
// src/utils/all-image-sources.ts
|
|
513
|
+
function walkAllImageSources(tree, visit) {
|
|
514
|
+
walkImageLikeSources(tree, visit);
|
|
515
|
+
walkBackgroundImageSources(tree, visit);
|
|
516
|
+
walkAtomicImageSources(tree, visit);
|
|
517
|
+
walkAtomicBackgroundImageSources(tree, visit);
|
|
518
|
+
}
|
|
519
|
+
|
|
519
520
|
// src/utils/image-size-key.ts
|
|
520
521
|
function buildImageSizeKey({ id, size }) {
|
|
521
522
|
return `${id}:${size || "full"}`;
|
|
@@ -524,15 +525,11 @@ function buildImageSizeKey({ id, size }) {
|
|
|
524
525
|
// src/utils/page-attachments.ts
|
|
525
526
|
function extractImageSizeRequests(tree) {
|
|
526
527
|
const keys = /* @__PURE__ */ new Set();
|
|
527
|
-
|
|
528
|
+
walkAllImageSources(tree, ({ media }) => {
|
|
528
529
|
if (media.id) {
|
|
529
530
|
keys.add(buildImageSizeKey({ id: media.id, size: media.size }));
|
|
530
531
|
}
|
|
531
|
-
};
|
|
532
|
-
walkImageLikeSources(tree, ({ media }) => collect(media));
|
|
533
|
-
walkBackgroundImageSources(tree, ({ media }) => collect(media));
|
|
534
|
-
walkAtomicImageSources(tree, ({ media }) => collect(media));
|
|
535
|
-
walkAtomicBackgroundImageSources(tree, ({ media }) => collect(media));
|
|
532
|
+
});
|
|
536
533
|
return Array.from(keys).sort();
|
|
537
534
|
}
|
|
538
535
|
|
|
@@ -2293,6 +2290,21 @@ var audit10 = {
|
|
|
2293
2290
|
// src/audits/images-alt-text.ts
|
|
2294
2291
|
var import_i18n29 = require("@wordpress/i18n");
|
|
2295
2292
|
|
|
2293
|
+
// src/utils/alt-text-image-sources.ts
|
|
2294
|
+
function walkAltTextImageSources(tree, visit) {
|
|
2295
|
+
walkImageLikeSources(tree, visit);
|
|
2296
|
+
walkAtomicImageSources(tree, visit, ATOMIC_CONTENT_IMAGE_PROP_KEYS);
|
|
2297
|
+
}
|
|
2298
|
+
function hasAltTextImages(tree) {
|
|
2299
|
+
let found = false;
|
|
2300
|
+
walkAltTextImageSources(tree, ({ media }) => {
|
|
2301
|
+
if (media.id || media.url) {
|
|
2302
|
+
found = true;
|
|
2303
|
+
}
|
|
2304
|
+
});
|
|
2305
|
+
return found;
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2296
2308
|
// src/utils/image-alt.ts
|
|
2297
2309
|
function hasMeaningfulAlt(media, pageContext) {
|
|
2298
2310
|
if (!media.id && !media.url) {
|
|
@@ -2319,14 +2331,14 @@ var audit11 = {
|
|
|
2319
2331
|
severity: "error",
|
|
2320
2332
|
weight: 10,
|
|
2321
2333
|
evaluate: (ctx) => {
|
|
2322
|
-
if (!
|
|
2334
|
+
if (!hasAltTextImages(ctx.elements.tree)) {
|
|
2323
2335
|
return { status: "skipped", reason: (0, import_i18n29.__)("No images", "elementor") };
|
|
2324
2336
|
}
|
|
2325
2337
|
const isReady = ctx.pageContext.ally_plugin_active;
|
|
2326
2338
|
const violations = [];
|
|
2327
2339
|
const failedWidgetIds = /* @__PURE__ */ new Set();
|
|
2328
2340
|
let missingAltImageCount = 0;
|
|
2329
|
-
|
|
2341
|
+
walkAltTextImageSources(ctx.elements.tree, ({ node, media }) => {
|
|
2330
2342
|
if (!isImageSourcePresent(media) || hasMeaningfulAlt(media, ctx.pageContext)) {
|
|
2331
2343
|
return;
|
|
2332
2344
|
}
|
|
@@ -2378,10 +2390,7 @@ var audit12 = {
|
|
|
2378
2390
|
inefficientImageFormatCount++;
|
|
2379
2391
|
offendingElementIds.add(node.id);
|
|
2380
2392
|
};
|
|
2381
|
-
|
|
2382
|
-
walkBackgroundImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2383
|
-
walkAtomicImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2384
|
-
walkAtomicBackgroundImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2393
|
+
walkAllImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2385
2394
|
if (!hasAnyImage) {
|
|
2386
2395
|
return { status: "skipped", reason: (0, import_i18n30.__)("No images", "elementor") };
|
|
2387
2396
|
}
|
|
@@ -2431,10 +2440,7 @@ var audit13 = {
|
|
|
2431
2440
|
const currentMax = widgetMaxKb.get(node.id) ?? 0;
|
|
2432
2441
|
widgetMaxKb.set(node.id, Math.max(currentMax, kb));
|
|
2433
2442
|
};
|
|
2434
|
-
|
|
2435
|
-
walkBackgroundImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2436
|
-
walkAtomicImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2437
|
-
walkAtomicBackgroundImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2443
|
+
walkAllImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2438
2444
|
if (!hasAnyImage) {
|
|
2439
2445
|
return { status: "skipped", reason: (0, import_i18n31.__)("No images", "elementor") };
|
|
2440
2446
|
}
|