diff --git a/.gitignore b/.gitignore index bede255a91d..96c7dfd7cfb 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ data.proposed.json # Ignore files created & used by pages & 11ty /_site/** + +# Local spec URL fragment reports (npm run test:specs -- --report) +reports/ diff --git a/.prettierignore b/.prettierignore index 4d3b79a7e8c..37a0b11137d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -14,3 +14,4 @@ towards-features.md /features/draft /scripts/schema.ts /scripts/specs.ts +/reports diff --git a/features/anchor-positioning-transforms.yml b/features/anchor-positioning-transforms.yml index f628a2b6efe..f9679364c2f 100644 --- a/features/anchor-positioning-transforms.yml +++ b/features/anchor-positioning-transforms.yml @@ -1,6 +1,6 @@ name: Anchor positioning transforms description: Anchor positioned elements take CSS transforms on their anchor elements into account. -spec: https://drafts.csswg.org/css-anchor-position-1/#anchoring +spec: https://drafts.csswg.org/css-anchor-position-1/#anchor-positioning group: anchor-positioning compat_features: - css.properties.anchor-name.position_after_layout diff --git a/features/anchor-positioning.yml b/features/anchor-positioning.yml index b1d8e83bbf0..41e6ce94606 100644 --- a/features/anchor-positioning.yml +++ b/features/anchor-positioning.yml @@ -1,6 +1,6 @@ name: Anchor positioning description: Anchor positioning places an element based on the position of another element. For example, you can place a tooltip next to the content it references. -spec: https://drafts.csswg.org/css-anchor-position-1/#anchoring +spec: https://drafts.csswg.org/css-anchor-position-1/#anchor-positioning group: anchor-positioning caniuse: css-anchor-positioning compat_features: diff --git a/features/array-iterators.yml b/features/array-iterators.yml index 5cbea431c33..9ebfcc13486 100644 --- a/features/array-iterators.yml +++ b/features/array-iterators.yml @@ -1,7 +1,7 @@ name: Array iterators description: Arrays are iterable with the `for … of` statement and enumerable with the methods `entries()`, `keys()`, and `values()`. spec: - - https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype-@@iterator + - https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype-%25symbol.iterator%25 - https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.entries - https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.keys - https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.values diff --git a/features/background-attachment.yml b/features/background-attachment.yml index 22623988d41..7bf64afeada 100644 --- a/features/background-attachment.yml +++ b/features/background-attachment.yml @@ -1,6 +1,6 @@ name: background-attachment description: The `background-attachment` CSS property sets whether an element's background image or gradient moves as the element scrolls. -spec: https://drafts.csswg.org/css-backgrounds-3/#the-background-attachment +spec: https://drafts.csswg.org/css-backgrounds-3/#background-attachment group: background caniuse: background-attachment # TODO: https://github.com/web-platform-dx/web-features/issues/1971 diff --git a/features/calc.yml b/features/calc.yml index 9a32137ab6f..716ba7142f2 100644 --- a/features/calc.yml +++ b/features/calc.yml @@ -1,6 +1,6 @@ name: calc() description: The `calc()` CSS function computes mathematical expressions such a `calc(100%/3 - 1em)`. -spec: https://drafts.csswg.org/css-values-3/#calc-notation +spec: https://drafts.csswg.org/css-values-3/#funcdef-calc group: css caniuse: calc status: diff --git a/features/contain-inline-size.yml b/features/contain-inline-size.yml index df3e0e07ff9..25c1f2b2947 100644 --- a/features/contain-inline-size.yml +++ b/features/contain-inline-size.yml @@ -1,6 +1,6 @@ name: Inline-size containment description: "The `contain: inline-size` CSS declaration prevents the element's inline dimension from being set by the element's contents. This permits the browser to avoid slower layout calculations." -spec: https://drafts.csswg.org/css-contain-3/#containment-inline-size +spec: https://drafts.csswg.org/css-contain-2/#containment-inline-size group: containment compat_features: - css.properties.contain.inline-size diff --git a/features/custom-ellipses.yml b/features/custom-ellipses.yml index 22f93597022..1387c5019eb 100644 --- a/features/custom-ellipses.yml +++ b/features/custom-ellipses.yml @@ -1,5 +1,5 @@ name: Custom ellipses description: The `text-overflow` CSS property with a string value sets the string representing clipped text. -spec: https://drafts.csswg.org/css-overflow-4/#overflow-string +spec: https://drafts.csswg.org/css-overflow-4/#text-overflow compat_features: - css.properties.text-overflow.string diff --git a/features/display-animation.yml b/features/display-animation.yml index 3ef4c1c6fab..401d8245b1a 100644 --- a/features/display-animation.yml +++ b/features/display-animation.yml @@ -2,5 +2,5 @@ name: display animation description: "You can animate elements between `display: none` and any other `display` value or animate between `content-visibility: hidden` and any other `content-visibility` value. This also applies to transitions." spec: - https://drafts.csswg.org/css-display-4/#display-animation - - https://drafts.csswg.org/css-contain-3/#content-visibility-animation + - https://drafts.csswg.org/css-contain-2/#content-visibility-animation group: css diff --git a/features/fit-content-function.yml b/features/fit-content-function.yml index 813a69f835c..f9b9ceba4eb 100644 --- a/features/fit-content-function.yml +++ b/features/fit-content-function.yml @@ -1,6 +1,6 @@ name: fit-content() description: The `fit-content()` CSS function, used outside of a grid layout property, clamps a length between `min-content` and `max-content`. -spec: https://drafts.csswg.org/css-sizing-3/#funcdef-width-fit-content +spec: https://drafts.csswg.org/css-sizing-4/#funcdef-width-fit-content group: layout compat_features: - css.properties.block-size.fit-content_function diff --git a/features/fit-content.yml b/features/fit-content.yml index 1b963769691..fdbfaa3e16a 100644 --- a/features/fit-content.yml +++ b/features/fit-content.yml @@ -1,6 +1,6 @@ name: fit-content description: The `fit-content` CSS keyword expands a box as needed to fit its contents until the maximum size is reached, preserving the content's preferred aspect ratio. -spec: https://drafts.csswg.org/css-sizing-4/#valdef-width-fit-content +spec: https://drafts.csswg.org/css-sizing-3/#valdef-width-fit-content group: layout compat_features: - css.properties.height.fit-content diff --git a/features/font-family-math.yml b/features/font-family-math.yml index c004f4e5a23..f547df5cfd0 100644 --- a/features/font-family-math.yml +++ b/features/font-family-math.yml @@ -1,6 +1,6 @@ name: Math font family description: "The `font-family: math` CSS declaration uses the browser default font face for displaying mathematical expressions." -spec: https://drafts.csswg.org/css-fonts-4/#math-def +spec: https://drafts.csswg.org/css-fonts-4/#valdef-font-family-math # TODO: https://github.com/web-platform-dx/web-features/issues/1971 # Status changed: https://github.com/web-platform-dx/web-features/pull/3867 # 2026-03-16 — low → false — Upstream data incorrectly reported that `font-family: math` shipped in Firefox 145. It actually shipped in Firefox 149. diff --git a/features/font-family-system.yml b/features/font-family-system.yml index 7e64a7be344..ce11c5dcb0d 100644 --- a/features/font-family-system.yml +++ b/features/font-family-system.yml @@ -1,6 +1,6 @@ name: System font description: "The `font-family: system-ui` CSS declaration uses the operating system default font for text." -spec: https://drafts.csswg.org/css-fonts-4/#system-ui-def +spec: https://drafts.csswg.org/css-fonts-4/#valdef-font-family-system-ui caniuse: font-family-system-ui compat_features: - css.properties.font-family.system-ui diff --git a/features/font-family-ui.yml b/features/font-family-ui.yml index aa71aae75ec..b9d684edb31 100644 --- a/features/font-family-ui.yml +++ b/features/font-family-ui.yml @@ -1,6 +1,6 @@ name: UI fonts description: The `ui-serif`, `ui-sans-serif`, `ui-monospace` and `ui-rounded` values for the `font-family` CSS property use device-default user interface fonts for text. -spec: https://drafts.csswg.org/css-fonts-4/#ui-serif-def +spec: https://drafts.csswg.org/css-fonts-4/#valdef-font-family-ui-serif caniuse: extended-system-fonts group: fonts compat_features: diff --git a/features/gif.yml b/features/gif.yml index 3067136431b..f058fe06206 100644 --- a/features/gif.yml +++ b/features/gif.yml @@ -1,6 +1,6 @@ name: GIF description: The GIF (Graphics Interchange Format) image format is a raster graphics file format with animation and lossless compression. spec: - - https://www.w3.org/Graphics/GIF/spec-gif89a.txt#top + - https://www.w3.org/Graphics/GIF/spec-gif89a.txt compat_features: - mediatypes.image.gif diff --git a/features/hyphens.yml b/features/hyphens.yml index 329d00751e8..4c8a261d947 100644 --- a/features/hyphens.yml +++ b/features/hyphens.yml @@ -2,7 +2,7 @@ name: Hyphenation # The description should be revisited when support notes are added. # https://github.com/web-platform-dx/web-features/issues/915 description: The `hyphens` CSS property controls when long words are broken by line wrapping. Although called `hyphens`, the property applies to word-splitting behavior across languages, such as customary spelling changes or the use of other characters. Support for non-English languages varies significantly. -spec: https://drafts.csswg.org/css-text-3/#hyphens-property +spec: https://drafts.csswg.org/css-text-3/#propdef-hyphens caniuse: css-hyphens group: css compat_features: diff --git a/features/indeterminate.yml b/features/indeterminate.yml index 75db3eac555..bd8487cde50 100644 --- a/features/indeterminate.yml +++ b/features/indeterminate.yml @@ -1,7 +1,7 @@ name: ":indeterminate" description: The `:indeterminate` CSS pseudo-class selects any form element whose state is indeterminate, such as checkboxes that have been set to an indeterminate state with JavaScript, or radio buttons which are members of a group in which all radio buttons are unchecked. spec: - - https://drafts.csswg.org/selectors-4/#indeterminate + - https://drafts.csswg.org/selectors-4/#indeterminate-pseudo - https://html.spec.whatwg.org/multipage/semantics-other.html#selector-indeterminate group: forms caniuse: css-indeterminate-pseudo diff --git a/features/intl.yml b/features/intl.yml index 0f89005d9e3..6c02af26c31 100644 --- a/features/intl.yml +++ b/features/intl.yml @@ -1,7 +1,7 @@ name: Intl description: "The `Intl` API provides language sensitive string comparison, number formatting, date and time formatting, and more." group: intl -spec: https://tc39.es/ecma402/#introduction +spec: https://tc39.es/ecma402/ caniuse: internationalization status: compute_from: javascript.builtins.Intl diff --git a/features/iterators.yml b/features/iterators.yml index b56d9c21634..2eac4a39486 100644 --- a/features/iterators.yml +++ b/features/iterators.yml @@ -3,7 +3,7 @@ description: The `for...of` loop operates on a sequence of values sourced from a group: iterators snapshot: ecmascript-2015 spec: - - https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%iteratorprototype%-object + - https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-%25iterator.prototype%25-object - https://tc39.es/ecma262/multipage/ecmascript-language-statements-and-declarations.html#sec-for-in-and-for-of-statements status: compute_from: javascript.statements.for_of diff --git a/features/javascript.yml b/features/javascript.yml index 2d655aea7cb..6e826a4e2bf 100644 --- a/features/javascript.yml +++ b/features/javascript.yml @@ -1,6 +1,6 @@ name: JavaScript (initial core language support) description: JavaScript is a programming language that runs in browsers, usually through the ` + +`; +} // Ensure every exception in defaultAllowlist is needed for (const [allowedUrl, message] of defaultAllowlist) { @@ -275,16 +385,46 @@ for (const [id, data] of Object.entries(features)) { logger.error(`Invalid URL "${spec}" found in spec for "${data.name}"`); errors++; } - if (url && !isOK(url)) { - logger.error(`URL for ${id} not in web-specs: ${url.toString()}`); - suggestSpecs(url); - errors++; + if (url) { + const pageResult = isOK(url); + if (!pageResult) { + logger.error(`URL for ${id} not in web-specs: ${url.toString()}`); + suggestSpecs(url); + errors++; + } else if (pageResult === "web-specs") { + // Allowlisted specs aren't in webref, so only web-specs + // matches get their fragment checked. + const result = validateSpecFragment(url); + fragmentReport.push({ feature: id, url: url.toString(), result }); + if (result.status === "invalid") { + if (result.reason === "text-fragment") { + logger.log(fragmentLogLevel, `Text fragment in spec URL for ${id}: ${url.toString()}\nText fragments (:~:text=) are not allowed in spec URLs; link a definition or heading id instead.`); + } else { + logger.log(fragmentLogLevel, `Unknown fragment in spec URL for ${id}: ${url.toString()}\nCheck that the fragment (#) is a definition or heading id in the spec, or link a more current anchor.`); + } + fragmentProblems++; + if (fragmentErrorsAreFatal) { + errors++; + } + } + } } checkedSpecs++; } checkedFeatures++; } +if (process.argv.includes("--report")) { + const reportPath = path.join(import.meta.dirname, "..", "reports", "spec-fragments.html"); + fs.mkdirSync(path.dirname(reportPath), { recursive: true }); + fs.writeFileSync(reportPath, formatFragmentReport(fragmentReport)); + console.log(`\nFragment report written to ${path.relative(process.cwd(), reportPath)}`); +} + +if (fragmentProblems) { + console.log(`\n${fragmentProblems} spec URL(s) have fragments unknown to @webref/xref${fragmentErrorsAreFatal ? "" : " (warnings only)"}, see https://github.com/web-platform-dx/web-features/issues/84`); +} + if (errors) { console.log(`\nChecked ${checkedSpecs} specs in ${checkedFeatures} features, found ${errors} error(s)`); process.exit(1); diff --git a/scripts/webref-xref.d.ts b/scripts/webref-xref.d.ts new file mode 100644 index 00000000000..7547cb4d5b7 --- /dev/null +++ b/scripts/webref-xref.d.ts @@ -0,0 +1,29 @@ +// Type declarations for @webref/xref, which ships no types. +// API: https://github.com/w3c/webref/blob/main/packages-auto/xref/README.md +declare module "@webref/xref" { + interface XrefEntry { + id?: string; + href: string; + title?: string; + linkingText?: string[]; + type?: string; + spec: string; + version: "nightly" | "release"; + } + + interface XrefMatch { + source: "dfns" | "headings"; + entry: XrefEntry; + } + + interface LookupOptions { + standing?: "good" | "pending" | "discontinued"; + version?: "nightly" | "release"; + series?: boolean; + } + + function setup(rootFolder?: string): void; + function lookup(url: string, options?: LookupOptions): XrefMatch[]; + + export { setup, lookup, XrefEntry, XrefMatch, LookupOptions }; +}