@webref/elements (original) (raw)
Markup elements of the Web platform and associated Web IDL interfaces
This package contains a list per spec of markup elements that compose the Web platform, scraped from the latest versions of web platform specifications in webref, along with the name of the Web IDL interface that these elements implement. Fixes are applied to ensure that guarantees.
API
The async listAll()
method resolves with an object where the keys are spec shortnames, and the values are the data for that spec. Example:
const elements = require('@webref/elements');
elements.listAll().then(all => { for (const [shortname, data] of Object.entries(all)) { // do something with the json object } });
For each spec, value is an object with a spec
property that describes the specification, and an elements
property that lists elements defined in the spec, as an array of objects with name
, interface
, href
, and obsolete
properties. The interface
property is not present for elements that do not implement an interface:
const elements = require('@webref/elements');
elements.listAll().then(all => {
for (const [shortname, data] of Object.entries(all)) {
console.log();
console.log(data.spec.title);
for (const el of data.elements) {
if (el.interface) {
console.log(- <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi>e</mi><mi>l</mi><mi mathvariant="normal">.</mi><mi>n</mi><mi>a</mi><mi>m</mi><mi>e</mi></mrow><mi>i</mi><mi>m</mi><mi>p</mi><mi>l</mi><mi>e</mi><mi>m</mi><mi>e</mi><mi>n</mi><mi>t</mi><mi>s</mi></mrow><annotation encoding="application/x-tex">{el.name} implements </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord">.</span><span class="mord mathnormal">nam</span><span class="mord mathnormal">e</span></span><span class="mord mathnormal">im</span><span class="mord mathnormal" style="margin-right:0.01968em;">pl</span><span class="mord mathnormal">e</span><span class="mord mathnormal">m</span><span class="mord mathnormal">e</span><span class="mord mathnormal">n</span><span class="mord mathnormal">t</span><span class="mord mathnormal">s</span></span></span></span>{el.interface}
);
}
else {
console.log(- ${el.name} does not implement an interface
);
}
}
}
});
The href
property is the URL to the definition of the element in the specification. The property is always set.
The obsolete
property is a boolean flag, only present (and set to true
) for elements that are obsolete.
Guarantees
The following guarantees are provided by this package:
- All Web IDL interfaces exist in the latest version of the @webref/idl package at the time the
@webref/elements
package is released. - All elements link back to their definition in the spec.