lighthouse 11.7.0-dev.20240401 → 11.7.0-dev.20240403

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.
@@ -35,7 +35,6 @@ class TargetSize extends AxeAudit {
35
35
  title: str_(UIStrings.title),
36
36
  failureTitle: str_(UIStrings.failureTitle),
37
37
  description: str_(UIStrings.description),
38
- scoreDisplayMode: AxeAudit.SCORING_MODES.INFORMATIVE,
39
38
  requiredArtifacts: ['Accessibility'],
40
39
  };
41
40
  }
@@ -83,28 +83,44 @@ function processForProto(lhr) {
83
83
  }
84
84
 
85
85
  /**
86
- * Remove any found empty strings, as they are dropped after round-tripping anyway
86
+ * Execute `cb(obj, key)` on every object property where obj[key] is a string, recursively.
87
87
  * @param {any} obj
88
+ * @param {(obj: Record<string, string>, key: string) => void} cb
88
89
  */
89
- function removeStrings(obj) {
90
+ function iterateStrings(obj, cb) {
90
91
  if (obj && typeof obj === 'object' && !Array.isArray(obj)) {
91
92
  Object.keys(obj).forEach(key => {
92
- if (typeof obj[key] === 'string' && obj[key] === '') {
93
- delete obj[key];
94
- } else if (typeof obj[key] === 'object' || Array.isArray(obj[key])) {
95
- removeStrings(obj[key]);
93
+ if (typeof obj[key] === 'string') {
94
+ cb(obj, key);
95
+ } else {
96
+ iterateStrings(obj[key], cb);
96
97
  }
97
98
  });
98
99
  } else if (Array.isArray(obj)) {
99
100
  obj.forEach(item => {
100
101
  if (typeof item === 'object' || Array.isArray(item)) {
101
- removeStrings(item);
102
+ iterateStrings(item, cb);
102
103
  }
103
104
  });
104
105
  }
105
106
  }
106
107
 
107
- removeStrings(reportJson);
108
+ iterateStrings(reportJson, (obj, key) => {
109
+ const value = obj[key];
110
+
111
+ // Remove empty strings, as they are dropped after round-tripping anyway.
112
+ if (value === '') {
113
+ delete obj[key];
114
+ return;
115
+ }
116
+
117
+ // Sanitize lone surrogates.
118
+ // @ts-expect-error node 20
119
+ if (String.prototype.isWellFormed && !value.isWellFormed()) {
120
+ // @ts-expect-error node 20
121
+ obj[key] = value.toWellFormed();
122
+ }
123
+ });
108
124
 
109
125
  return reportJson;
110
126
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "11.7.0-dev.20240401",
4
+ "version": "11.7.0-dev.20240403",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {