You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Web IDL study: detect event handlers with no matching event (#785)
When an interface defines an event handler, there should always be an event
named after the event handler that targets the interface. The new `noEvent`
anomaly detects situations where the event is missing.
The analysis reports the two anomalies mentioned in:
w3c/webref#1216 (comment)
(The analysis reports additional anomalies when run on the raw extracts. That's
normal and due to missing event targets that get added during curation)
recordAnomaly(spec,'unexpectedEventHandler',`The interface \`${iface.name}\` defines an event handler \`${eventHandler.name}\` but does not inherit from \`EventTarget\``);
recordAnomaly(spec,'unexpectedEventHandler',`The interface \`${iface.name}\` defines an event handler \`${eventHandlers[0].name}\` but does not inherit from \`EventTarget\``);
// No event found with the same type that targets the interface
236
+
// directly, but one the events may target an interface that
237
+
// inherits from the interface, or may bubble on the interface.
238
+
event=events.find(e=>e.targets?.find(target=>{
239
+
constinheritanceFound=dfns[target]?.find(dfn=>
240
+
dfn.idl.type==='interface'&&
241
+
inheritsFrom(dfn.idl,iface.name));
242
+
if(inheritanceFound)returntrue;
243
+
if(!e.bubbles)returnfalse;
244
+
constbubblingPath=getBubblingPath(target);
245
+
if(!bubblingPath)returnfalse;
246
+
returnbubblingPath.find(bubblingIface=>
247
+
iface.name===bubblingIface||
248
+
inheritsFrom(iface,bubblingIface));
249
+
}));
250
+
}
251
+
if(!event){
252
+
recordAnomaly(spec,'noEvent',`The interface \`${iface.name}\` defines an event handler \`${eventHandler.name}\` but no event named "${eventType}" targets it`);
0 commit comments