@hyperframes/lint 0.8.15 → 0.8.17
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 +11 -3
- package/dist/browser.js.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -776,6 +776,14 @@ function hasAttrName(tagSource, attr) {
|
|
|
776
776
|
const attrs = tagSource.replace(/^<\s*[a-z][\w:-]*/i, "");
|
|
777
777
|
return new RegExp(`(?:^|\\s)${escaped}(?:\\s*=|\\s|/?>)`, "i").test(attrs);
|
|
778
778
|
}
|
|
779
|
+
function mediaHasResolvableSrc(tag, tags) {
|
|
780
|
+
if (readAttr(tag.raw, "src")) return true;
|
|
781
|
+
const end = tag.closeIndex ?? tag.endIndex;
|
|
782
|
+
if (end == null) return false;
|
|
783
|
+
return tags.some(
|
|
784
|
+
(child) => child.name === "source" && child.index > tag.index && child.index < end && Boolean(readAttr(child.raw, "src"))
|
|
785
|
+
);
|
|
786
|
+
}
|
|
779
787
|
function classNamesFromAttr(classAttr) {
|
|
780
788
|
if (!classAttr) return [];
|
|
781
789
|
return classAttr.split(/\s+/).filter(Boolean);
|
|
@@ -1174,7 +1182,7 @@ var mediaRules = [
|
|
|
1174
1182
|
if (tag.name !== "video" && tag.name !== "audio") continue;
|
|
1175
1183
|
const hasDataStart = readAttr(tag.raw, "data-start");
|
|
1176
1184
|
const hasId = readAttr(tag.raw, "id");
|
|
1177
|
-
const hasSrc =
|
|
1185
|
+
const hasSrc = mediaHasResolvableSrc(tag, tags);
|
|
1178
1186
|
if (hasSrc && !hasDataStart) {
|
|
1179
1187
|
findings.push({
|
|
1180
1188
|
code: "media_missing_data_start",
|
|
@@ -1209,9 +1217,9 @@ var mediaRules = [
|
|
|
1209
1217
|
findings.push({
|
|
1210
1218
|
code: "media_missing_src",
|
|
1211
1219
|
severity: "error",
|
|
1212
|
-
message: `<${tag.name} id="${hasId}"> has data-start but no src
|
|
1220
|
+
message: `<${tag.name} id="${hasId}"> has data-start but no src (on the element or a <source> child). The renderer cannot load this media.`,
|
|
1213
1221
|
elementId: hasId,
|
|
1214
|
-
fixHint: `Add
|
|
1222
|
+
fixHint: `Add src on the <${tag.name}> element, or a <source src="..."> child.`,
|
|
1215
1223
|
snippet: truncateSnippet(tag.raw)
|
|
1216
1224
|
});
|
|
1217
1225
|
}
|