nnw-theme 1.0.1 → 1.0.2
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/browser.js +21 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -128,6 +128,8 @@ export function failures(state) {
|
|
|
128
128
|
found.push("horizontal document overflow");
|
|
129
129
|
if (state.brokenImages.length)
|
|
130
130
|
found.push(`broken images: ${pyReprList(state.brokenImages)}`);
|
|
131
|
+
if (state.collapsedImages.length)
|
|
132
|
+
found.push(`images drawn at zero size: ${pyReprList(state.collapsedImages)}`);
|
|
131
133
|
found.push(...(state.footnotes ?? []));
|
|
132
134
|
if (state.blocked.length)
|
|
133
135
|
found.push(`external requests: ${pyReprList(state.blocked)}`);
|
|
@@ -149,6 +151,25 @@ function pageState() {
|
|
|
149
151
|
brokenImages: [...document.images]
|
|
150
152
|
.filter((image) => image.complete && image.naturalWidth === 0)
|
|
151
153
|
.map((image) => image.currentSrc || image.src),
|
|
154
|
+
// A loaded image the theme lays out at no size, such as a percentage width
|
|
155
|
+
// inside a shrink-to-fit float, which WebKit resolves to zero. Images that are
|
|
156
|
+
// not laid out at all (display: none, a closed <details>) are deliberate, and
|
|
157
|
+
// so is one the article itself sizes to zero, like a tracking pixel.
|
|
158
|
+
collapsedImages: [...document.images]
|
|
159
|
+
.filter((image) => {
|
|
160
|
+
if (!image.complete || image.naturalWidth < 2 || image.naturalHeight < 2)
|
|
161
|
+
return false;
|
|
162
|
+
if (!image.getClientRects().length)
|
|
163
|
+
return false;
|
|
164
|
+
const zero = (value) => value !== null && /^\s*0(px)?\s*$/i.test(value);
|
|
165
|
+
if ([image.getAttribute("width"), image.getAttribute("height")].some(zero))
|
|
166
|
+
return false;
|
|
167
|
+
if ([image.style.width, image.style.height].some(zero))
|
|
168
|
+
return false;
|
|
169
|
+
const box = image.getBoundingClientRect();
|
|
170
|
+
return box.width < 1 || box.height < 1;
|
|
171
|
+
})
|
|
172
|
+
.map((image) => image.currentSrc || image.src),
|
|
152
173
|
};
|
|
153
174
|
}
|
|
154
175
|
/**
|