Open Web data by the Mozilla Developer Network containing structured JSON data for web technologies including CSS properties, selectors, functions, at-rules, Web API inheritance, and localization strings used in MDN Web Docs
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Web API interface inheritance relationships and mixin implementations that describe the structure of the Web API object model.
Access complete inheritance relationships for Web API interfaces.
/**
* Web API interface inheritance data
* Maps interface names to their inheritance information
*/
const inheritance: InheritanceData;
interface InheritanceData {
[interfaceName: string]: InheritanceEntry;
}
interface InheritanceEntry {
/** The parent interface this interface inherits from, or null if no inheritance */
inherits: string | null;
/** Array of mixin interfaces this interface implements */
implements: string[];
}Usage Examples:
const { api } = require('mdn-data');
// Check what DocumentFragment inherits from
const docFragment = api.inheritance.DocumentFragment;
console.log(docFragment);
// Output: { "inherits": "Node", "implements": ["ParentNode", "LegacyQueryInterface"] }
// Find all interfaces that inherit from EventTarget
const eventTargetChildren = Object.entries(api.inheritance)
.filter(([name, data]) => data.inherits === 'EventTarget')
.map(([name]) => name);
// Check what mixins an interface implements
const analyserNode = api.inheritance.AnalyserNode;
console.log(analyserNode.implements);
// Output: ["AudioNodePassThrough"]
// Find interfaces with no parent (top-level interfaces)
const topLevelInterfaces = Object.entries(api.inheritance)
.filter(([name, data]) => data.inherits === null)
.map(([name]) => name);Direct access to specific interface inheritance information.
/**
* Get inheritance information for a specific interface
* @param interfaceName - Name of the Web API interface
* @returns Inheritance entry or undefined if not found
*/
function getInheritanceInfo(interfaceName: string): InheritanceEntry | undefined {
return api.inheritance[interfaceName];
}Helper patterns for navigating the inheritance hierarchy.
/**
* Common patterns for working with inheritance data
*/
// Get all parent interfaces in the inheritance chain
function getInheritanceChain(interfaceName: string): string[] {
const chain = [];
let current = api.inheritance[interfaceName];
while (current && current.inherits) {
chain.push(current.inherits);
current = api.inheritance[current.inherits];
}
return chain;
}
// Get all child interfaces that inherit from a given interface
function getChildInterfaces(parentInterface: string): string[] {
return Object.entries(api.inheritance)
.filter(([name, data]) => data.inherits === parentInterface)
.map(([name]) => name);
}
// Get all interfaces that implement a specific mixin
function getInterfacesImplementingMixin(mixinName: string): string[] {
return Object.entries(api.inheritance)
.filter(([name, data]) => data.implements.includes(mixinName))
.map(([name]) => name);
}The inheritance data provides:
inherits: nullimplements: []