reffy 16.1.0 → 16.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reffy",
3
- "version": "16.1.0",
3
+ "version": "16.1.2",
4
4
  "description": "W3C/WHATWG spec dependencies exploration companion. Features a short set of tools to study spec references as well as WebIDL term definitions and references found in W3C specifications.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,20 +32,20 @@
32
32
  "main": "index.js",
33
33
  "bin": "./reffy.js",
34
34
  "dependencies": {
35
- "ajv": "8.16.0",
35
+ "ajv": "8.17.1",
36
36
  "ajv-formats": "3.0.1",
37
37
  "commander": "12.1.0",
38
38
  "fetch-filecache-for-crawling": "5.1.1",
39
- "puppeteer": "22.13.0",
39
+ "puppeteer": "22.13.1",
40
40
  "semver": "^7.3.5",
41
41
  "web-specs": "3.13.1",
42
42
  "webidl2": "24.4.1"
43
43
  },
44
44
  "devDependencies": {
45
- "mocha": "10.6.0",
45
+ "mocha": "10.7.0",
46
46
  "respec": "35.1.1",
47
47
  "respec-hljs": "2.1.1",
48
- "rollup": "4.18.1",
48
+ "rollup": "4.19.0",
49
49
  "undici": "^6.1.0"
50
50
  },
51
51
  "overrides": {
@@ -4,9 +4,9 @@
4
4
 
5
5
  "type": "object",
6
6
  "additionalProperties": false,
7
- "required": ["spec", "dfns"],
7
+ "required": ["spec", "algorithms"],
8
8
  "properties": {
9
9
  "spec": { "$ref": "../../common.json#/$defs/specInExtract" },
10
- "dfns": { "$ref": "../../browserlib/extract-algorithms.json" }
10
+ "algorithms": { "$ref": "../../browserlib/extract-algorithms.json" }
11
11
  }
12
12
  }
@@ -371,8 +371,22 @@ function getDefinedNameIn(el) {
371
371
  else {
372
372
  name += getTextContent(dfn);
373
373
  }
374
- const href = dfn.id ? getAbsoluteUrl(dfn) : null;
375
- return { name, href };
374
+ if (dfn.id) {
375
+ return { name, href: getAbsoluteUrl(dfn) };
376
+ }
377
+ else {
378
+ // Two known exceptions to the rule:
379
+ // - one due to CSS 2.1 not following the definitions data model:
380
+ // https://www.w3.org/TR/CSS21/visudet.html#containing-block-details
381
+ // - the other due to HTML still containing dfns without IDs as well,
382
+ // including one for an algorithm:
383
+ // https://html.spec.whatwg.org/multipage/server-sent-events.html#processField
384
+ // It's possible to find an ID in both cases. But it's not clear that
385
+ // CSS 2.1 algorithms are real algorithms; and it seems doable to fix the
386
+ // HTML spec. Let's just return the name without href, not to end up
387
+ // with a null `href` that the JSON schema forbids.
388
+ return { name };
389
+ }
376
390
  }
377
391
  else {
378
392
  const heading = el.querySelector('h2[id],h3[id],h4[id],h5[id],h6[id]');
@@ -390,14 +404,17 @@ function getDefinedNameIn(el) {
390
404
  */
391
405
  function findIntroParagraph(algo) {
392
406
  let paragraph;
393
- let container = algo.root.closest('.algorithm');
407
+ let container = algo.root.closest('li,.algorithm');
394
408
  while (container) {
395
409
  const dfn = container.querySelector('dfn');
396
- if (dfn) {
397
- paragraph = dfn.closest('p,div');
410
+ if (dfn && !algo.root.contains(dfn)) {
411
+ paragraph = dfn.closest('p,div,li');
398
412
  break;
399
413
  }
400
- container = container.parentElement.closest('.algorithm');
414
+ if (container.nodeName === 'LI') {
415
+ break;
416
+ }
417
+ container = container.parentElement.closest('li,.algorithm');
401
418
  }
402
419
 
403
420
  if (!paragraph) {
@@ -427,9 +444,10 @@ function getAlgorithmInfo(algo, context) {
427
444
  // Note some specs add the "algorithm" class to the `<ol>` and to the
428
445
  // wrapping container, and define the name in the wrapping container.
429
446
  let info = {};
447
+
430
448
  let container = algo.root.closest('.algorithm');
431
- while (container) {
432
- if (container && !context?.nested) {
449
+ if (!context?.nested) {
450
+ while (container) {
433
451
  if (container.getAttribute('data-algorithm')) {
434
452
  info.name = normalize(container.getAttribute('data-algorithm'));
435
453
  if (container.getAttribute('data-algorithm-for')) {
@@ -448,13 +466,15 @@ function getAlgorithmInfo(algo, context) {
448
466
  info.href = dfn.href;
449
467
  }
450
468
  }
451
- break;
452
469
  }
453
470
  else {
454
471
  info = getDefinedNameIn(container);
472
+ if (info.name || info.href) {
473
+ break;
474
+ }
455
475
  }
476
+ container = container.parentElement.closest('.algorithm');
456
477
  }
457
- container = container.parentElement.closest('.algorithm');
458
478
  }
459
479
 
460
480
  // Get the introductory prose from the previous paragraph