From 35d1671715f86adc57545c7d938bf1caa35eb983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Daoust?= Date: Fri, 7 Mar 2025 10:51:17 +0100 Subject: [PATCH] Dfns extraction: expand logic that skips imported definitions (#1789) The crawler expected "imported definitions" to use `` as the wrapping element with an inner `` element. The Source map format spec used the opposite pattern. This update expands the logic accordingly. The Source map format spec actually swapped back the elements, but there are a couple of other specs that use the same pattern (Audiobooks and the JSON-LD API), and more specs may elect to do that in the future as well. Close #1788. --- src/browserlib/extract-dfns.mjs | 4 +++- tests/extract-dfns.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/browserlib/extract-dfns.mjs b/src/browserlib/extract-dfns.mjs index 3c1efe1d..f5951969 100644 --- a/src/browserlib/extract-dfns.mjs +++ b/src/browserlib/extract-dfns.mjs @@ -341,7 +341,9 @@ export default function (spec, idToHeading = {}) { // (pending a proper dfns curation process, see: // https://github.com/w3c/webref/issues/789) .filter(node => { - const link = node.querySelector('a[href^="http"]'); + const link = + node.querySelector('a[href^="http"]') ?? + node.closest('a[href^="http"]'); return !link || (node.textContent.trim() !== link.textContent.trim()) || (link.href === 'https://www.w3.org/TR/CSS2/syndata.html#vendor-keywords'); diff --git a/tests/extract-dfns.js b/tests/extract-dfns.js index 72fd06f8..0acc1616 100644 --- a/tests/extract-dfns.js +++ b/tests/extract-dfns.js @@ -325,6 +325,12 @@ const tests = [ changesToBaseDfn: [], spec: "html" }, + { + title: "ignores definitions imported in the Source map format spec", + html: '
  • The byte sequence', + changesToBaseDfn: [], + spec: "sourcemap" + }, { "title": "extracts attribute definition from the SVG2 spec", html: `