reffy 15.1.0 → 15.2.0

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": "15.1.0",
3
+ "version": "15.2.0",
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",
@@ -65,8 +65,14 @@ module.exports = {
65
65
  })
66
66
  .filter(event => !!event);
67
67
 
68
+ // Before we clean and sort the result, we'll consolidate events that
69
+ // don't always bubble. We'll call them... "babbling" events. Such events
70
+ // should remain exceptions to the rule, and will likely be artificially
71
+ // created through some patching mechanism (in Webref typically) because
72
+ // the events extraction logic does not (yet?) support this scenario.
68
73
  return events
69
74
  .filter(event => !eventsToDrop.includes(event))
75
+ .filter(event => consolidateBabblingEvent(event, events))
70
76
  .map(event => {
71
77
  cleanTargetInterfaces(event, parsedInterfaces);
72
78
  delete event.spec;
@@ -223,3 +229,31 @@ function extendEvent(event, events) {
223
229
  { spec: event.spec.series.shortname },
224
230
  event.src?.href ? { href: event.src?.href } : {}));
225
231
  }
232
+
233
+
234
+ /**
235
+ * Consolidate events that got duplicated in the extract because they bubble
236
+ * or don't bubble depending on the target interface.
237
+ *
238
+ * We'll say that these events "babble" because they don't seem to know whether
239
+ * they bubble or not.
240
+ */
241
+ function consolidateBabblingEvent(event, events) {
242
+ if (event.mergedIntoAnotherEvent) {
243
+ return null;
244
+ }
245
+ const newTargets = events
246
+ .filter(e =>
247
+ e !== event && !e.isExtension && !e.mergedIntoAnotherEvent &&
248
+ e.href && e.href === event.href && e.cancelable === event.cancelable)
249
+ .map(e => {
250
+ // Flag the event as merged so that we can filter it out afterwards
251
+ e.mergedIntoAnotherEvent = true;
252
+ return e.targets;
253
+ })
254
+ .flat();
255
+ if (newTargets.length > 0) {
256
+ event.targets = (event.targets || []).concat(newTargets);
257
+ }
258
+ return event;
259
+ }