Skip to content

Commit 74042a1

Browse files
authored
Handle CLS with no sources (#623)
1 parent 0263378 commit 74042a1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/attribution/onCLS.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const onCLS = (
7272
layoutShiftManager._onAfterProcessingUnexpectedShift = (
7373
entry: LayoutShift,
7474
) => {
75-
if (entry.sources.length) {
75+
if (entry?.sources?.length) {
7676
const largestSource = getLargestLayoutShiftSource(entry.sources);
7777
if (largestSource) {
7878
const generateTargetFn = opts.generateTarget ?? getSelector;
@@ -88,7 +88,7 @@ export const onCLS = (
8888

8989
if (metric.entries.length) {
9090
const largestEntry = getLargestLayoutShiftEntry(metric.entries);
91-
if (largestEntry?.sources.length) {
91+
if (largestEntry?.sources?.length) {
9292
const largestSource = getLargestLayoutShiftSource(largestEntry.sources);
9393
if (largestSource) {
9494
attribution = {

0 commit comments

Comments
 (0)