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