@elementor/editor-audits 4.4.0-1130 → 4.4.0-1132
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.mjs
CHANGED
|
@@ -364,13 +364,14 @@ function recurse(nodes, parents, visit) {
|
|
|
364
364
|
}
|
|
365
365
|
|
|
366
366
|
// src/utils/atomic-image-sources.ts
|
|
367
|
-
var
|
|
368
|
-
|
|
367
|
+
var ATOMIC_CONTENT_IMAGE_PROP_KEYS = ["image"];
|
|
368
|
+
var ATOMIC_IMAGE_PROP_KEYS = [...ATOMIC_CONTENT_IMAGE_PROP_KEYS, "poster"];
|
|
369
|
+
function walkAtomicImageSources(tree, visit, propKeys = ATOMIC_IMAGE_PROP_KEYS) {
|
|
369
370
|
walkElements(tree, (node) => {
|
|
370
371
|
if (node.elType !== "widget") {
|
|
371
372
|
return;
|
|
372
373
|
}
|
|
373
|
-
for (const key of
|
|
374
|
+
for (const key of propKeys) {
|
|
374
375
|
const media = extractAtomicImageMedia(node.settings[key]);
|
|
375
376
|
if (media) {
|
|
376
377
|
visit({ node, media });
|
|
@@ -392,8 +393,9 @@ function extractAtomicImageMedia(imageProp) {
|
|
|
392
393
|
if (!id && !url) {
|
|
393
394
|
return null;
|
|
394
395
|
}
|
|
396
|
+
const alt = stringPropTypeUtil.extract(src.alt) ?? void 0;
|
|
395
397
|
const size = stringPropTypeUtil.extract(image.size) ?? void 0;
|
|
396
|
-
return { id, url, size };
|
|
398
|
+
return { id, url, alt, size };
|
|
397
399
|
}
|
|
398
400
|
|
|
399
401
|
// src/utils/atomic-background-image-sources.ts
|
|
@@ -448,15 +450,6 @@ function walkBackgroundImageSources(tree, visit) {
|
|
|
448
450
|
|
|
449
451
|
// src/utils/image-like-sources.ts
|
|
450
452
|
var IMAGE_LIKE_WIDGETS = /* @__PURE__ */ new Set(["image", "image-box", "image-carousel", "gallery", "image-gallery"]);
|
|
451
|
-
function hasPageImages(tree) {
|
|
452
|
-
let found = false;
|
|
453
|
-
walkImageLikeSources(tree, ({ media }) => {
|
|
454
|
-
if (media.id || media.url) {
|
|
455
|
-
found = true;
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
return found;
|
|
459
|
-
}
|
|
460
453
|
function walkImageLikeSources(tree, visit) {
|
|
461
454
|
walkElements(tree, (node) => {
|
|
462
455
|
if (node.elType !== "widget") {
|
|
@@ -488,6 +481,14 @@ function collectMediaFromNode(node) {
|
|
|
488
481
|
return sources;
|
|
489
482
|
}
|
|
490
483
|
|
|
484
|
+
// src/utils/all-image-sources.ts
|
|
485
|
+
function walkAllImageSources(tree, visit) {
|
|
486
|
+
walkImageLikeSources(tree, visit);
|
|
487
|
+
walkBackgroundImageSources(tree, visit);
|
|
488
|
+
walkAtomicImageSources(tree, visit);
|
|
489
|
+
walkAtomicBackgroundImageSources(tree, visit);
|
|
490
|
+
}
|
|
491
|
+
|
|
491
492
|
// src/utils/image-size-key.ts
|
|
492
493
|
function buildImageSizeKey({ id, size }) {
|
|
493
494
|
return `${id}:${size || "full"}`;
|
|
@@ -496,15 +497,11 @@ function buildImageSizeKey({ id, size }) {
|
|
|
496
497
|
// src/utils/page-attachments.ts
|
|
497
498
|
function extractImageSizeRequests(tree) {
|
|
498
499
|
const keys = /* @__PURE__ */ new Set();
|
|
499
|
-
|
|
500
|
+
walkAllImageSources(tree, ({ media }) => {
|
|
500
501
|
if (media.id) {
|
|
501
502
|
keys.add(buildImageSizeKey({ id: media.id, size: media.size }));
|
|
502
503
|
}
|
|
503
|
-
};
|
|
504
|
-
walkImageLikeSources(tree, ({ media }) => collect(media));
|
|
505
|
-
walkBackgroundImageSources(tree, ({ media }) => collect(media));
|
|
506
|
-
walkAtomicImageSources(tree, ({ media }) => collect(media));
|
|
507
|
-
walkAtomicBackgroundImageSources(tree, ({ media }) => collect(media));
|
|
504
|
+
});
|
|
508
505
|
return Array.from(keys).sort();
|
|
509
506
|
}
|
|
510
507
|
|
|
@@ -2277,6 +2274,21 @@ var audit10 = {
|
|
|
2277
2274
|
// src/audits/images-alt-text.ts
|
|
2278
2275
|
import { __ as __29 } from "@wordpress/i18n";
|
|
2279
2276
|
|
|
2277
|
+
// src/utils/alt-text-image-sources.ts
|
|
2278
|
+
function walkAltTextImageSources(tree, visit) {
|
|
2279
|
+
walkImageLikeSources(tree, visit);
|
|
2280
|
+
walkAtomicImageSources(tree, visit, ATOMIC_CONTENT_IMAGE_PROP_KEYS);
|
|
2281
|
+
}
|
|
2282
|
+
function hasAltTextImages(tree) {
|
|
2283
|
+
let found = false;
|
|
2284
|
+
walkAltTextImageSources(tree, ({ media }) => {
|
|
2285
|
+
if (media.id || media.url) {
|
|
2286
|
+
found = true;
|
|
2287
|
+
}
|
|
2288
|
+
});
|
|
2289
|
+
return found;
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2280
2292
|
// src/utils/image-alt.ts
|
|
2281
2293
|
function hasMeaningfulAlt(media, pageContext) {
|
|
2282
2294
|
if (!media.id && !media.url) {
|
|
@@ -2303,14 +2315,14 @@ var audit11 = {
|
|
|
2303
2315
|
severity: "error",
|
|
2304
2316
|
weight: 10,
|
|
2305
2317
|
evaluate: (ctx) => {
|
|
2306
|
-
if (!
|
|
2318
|
+
if (!hasAltTextImages(ctx.elements.tree)) {
|
|
2307
2319
|
return { status: "skipped", reason: __29("No images", "elementor") };
|
|
2308
2320
|
}
|
|
2309
2321
|
const isReady = ctx.pageContext.ally_plugin_active;
|
|
2310
2322
|
const violations = [];
|
|
2311
2323
|
const failedWidgetIds = /* @__PURE__ */ new Set();
|
|
2312
2324
|
let missingAltImageCount = 0;
|
|
2313
|
-
|
|
2325
|
+
walkAltTextImageSources(ctx.elements.tree, ({ node, media }) => {
|
|
2314
2326
|
if (!isImageSourcePresent(media) || hasMeaningfulAlt(media, ctx.pageContext)) {
|
|
2315
2327
|
return;
|
|
2316
2328
|
}
|
|
@@ -2362,10 +2374,7 @@ var audit12 = {
|
|
|
2362
2374
|
inefficientImageFormatCount++;
|
|
2363
2375
|
offendingElementIds.add(node.id);
|
|
2364
2376
|
};
|
|
2365
|
-
|
|
2366
|
-
walkBackgroundImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2367
|
-
walkAtomicImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2368
|
-
walkAtomicBackgroundImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2377
|
+
walkAllImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2369
2378
|
if (!hasAnyImage) {
|
|
2370
2379
|
return { status: "skipped", reason: __30("No images", "elementor") };
|
|
2371
2380
|
}
|
|
@@ -2415,10 +2424,7 @@ var audit13 = {
|
|
|
2415
2424
|
const currentMax = widgetMaxKb.get(node.id) ?? 0;
|
|
2416
2425
|
widgetMaxKb.set(node.id, Math.max(currentMax, kb));
|
|
2417
2426
|
};
|
|
2418
|
-
|
|
2419
|
-
walkBackgroundImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2420
|
-
walkAtomicImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2421
|
-
walkAtomicBackgroundImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2427
|
+
walkAllImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media));
|
|
2422
2428
|
if (!hasAnyImage) {
|
|
2423
2429
|
return { status: "skipped", reason: __31("No images", "elementor") };
|
|
2424
2430
|
}
|