Skip to content

Commit 7c99914

Browse files
NiedziolkaMichalsideshowbarker
authored andcommitted
Add fetchpriority attribute
1 parent d605dbc commit 7c99914

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

schema/html5/common.rnc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ common.attrs.other =
216216
list { w:string "render" }
217217
}
218218

219+
common.attrs.fetchpriority =
220+
attribute fetchpriority {
221+
w:string "high" | w:string "low" | w:string "auto"
222+
}
223+
219224
common.attrs.nonce =
220225
attribute nonce {
221226
string

schema/html5/core-scripting.rnc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ datatypes w = "http://whattf.org/datatype-draft"
3434
& script.attrs.integrity?
3535
& embedded.content.attrs.crossorigin?
3636
& common.attrs.blocking?
37+
& common.attrs.fetchpriority?
3738
& referrerpolicy?
3839
)
3940
script.attrs.src =

schema/html5/embed.rnc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace local = ""
2222
& img.attrs.ismap?
2323
& img.attrs.decoding?
2424
& img.attrs.loading?
25+
& common.attrs.fetchpriority?
2526
& img.attrs.border? # obsolete
2627
& referrerpolicy?
2728
& embedded.content.attrs.crossorigin?

schema/html5/meta.rnc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ datatypes w = "http://whattf.org/datatype-draft"
164164
& link.attrs.workertype?
165165
& link.attrs.imagesrcset?
166166
& link.attrs.imagesizes?
167+
& common.attrs.fetchpriority?
167168
# link.attrs.title included in common.attrs
168169
& embedded.content.attrs.crossorigin?
169170
& common.attrs.blocking?

src/nu/validator/checker/schematronequiv/Assertions.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,13 @@ private static void registerRequiredAncestorRole(String parent,
678678
ATTRIBUTES_WITH_IMPLICIT_STATE_OR_PROPERTY.add("required");
679679
ATTRIBUTES_WITH_IMPLICIT_STATE_OR_PROPERTY.add("rowspan");
680680
}
681+
682+
/**
683+
* Names of link types that are considered as "External Resource" according to https://html.spec.whatwg.org/multipage/links.html#linkTypes
684+
*/
685+
private static final String[] EXTERNAL_RESOURCE_LINK_REL = new String[] {
686+
"dns-prefetch", "icon", "manifest", "modulepreload", "pingback", "preconnect", "prefetch", "preload", "prerender", "stylesheet"
687+
};
681688

682689
private static final String h1WarningMessage = "Consider using the"
683690
+ " \u201Ch1\u201D element as a top-level heading only (all"
@@ -2908,6 +2915,11 @@ else if ("script" == localName) {
29082915
+ " \u201Cintegrity\u201D unless attribute"
29092916
+ " \u201Csrc\u201D is also specified.");
29102917
}
2918+
if (atts.getIndex("", "fetchpriority") > -1) {
2919+
warn("Element \u201Cscript\u201D should not have attribute"
2920+
+ " \u201Cfetchpriority\u201D unless attribute"
2921+
+ " \u201Csrc\u201D is also specified.");
2922+
}
29112923
}
29122924
if (atts.getIndex("", "type") > -1) {
29132925
String scriptType = atts.getValue("", "type").toLowerCase();
@@ -3365,6 +3377,12 @@ else if ("bdo" == localName && atts.getIndex("", "dir") < 0) {
33653377
+ " \u201Ctitle\u201D attribute with a"
33663378
+ " non-empty value.");
33673379
}
3380+
if (atts.getIndex("", "fetchpriority") > -1
3381+
&& Arrays.stream(EXTERNAL_RESOURCE_LINK_REL).noneMatch(relList::contains)) {
3382+
warn("A \u201Clink\u201D element with \u201Cfetchpriority\u201D"
3383+
+ " attribute should have a \u201Crel\u201D"
3384+
+ " attribute containing external resource type.");
3385+
}
33683386
if ((ancestorMask & BODY_MASK) != 0
33693387
&& (relList != null
33703388
&& !(relList.contains("dns-prefetch")

0 commit comments

Comments
 (0)