Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove code needed to extract element attributes #634

Merged
merged 3 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions src/browserlib/extract-dfns.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,6 @@ function preProcessHTML() {
const idlTree = parse(idl);
const idlInterfaces = idlTree.filter(item => item.type === "interface" || item.type === "interface mixin");

function fromIdToElement(id) {
switch(id) {
case "hyperlink": return "a,area";
case "mod": return "ins,del";
case "dim": return "img,iframe,embed,object,video";
// The spec lists img, but img doesn't have a form attribute
case "fae": return "button,fieldset,input,object,output,select,textarea";
case "fe": return "button,fieldset,input,object,output,select,textarea";
case "fs": return "form,button";
case "hx": return "h1,h2,h3,h4,h5,h6";
case "tdth": return "td,th";
// xml: attributes are id'd as xml-
// case "xml": return "all HTML elements";
case "xml": return undefined;

};
return id;
}

function fromIdToIdl(id) {
const specialInterfaceIds = {
"appcache": "ApplicationCache",
Expand Down Expand Up @@ -352,12 +333,6 @@ function preProcessHTML() {
[...document.querySelectorAll("dfn[id]:not([data-dfn-type]):not([data-skip])")]
.forEach(el => {
// Hard coded rules for special ids
// hyphen in attribute name throws off other match rules
if (el.id === "attr-form-accept-charset") {
el.dataset.dfnType = 'element-attr';
el.dataset.dfnFor = "form";
return;
}
// dom-style is defined elsewhere
if (el.id === "dom-style") {
el.dataset.dfnType = 'attribute';
Expand All @@ -375,33 +350,6 @@ function preProcessHTML() {
}
let m;

if ((m = el.id.match(/^attr-([^-]+)-([^-]+)$/))) {
// e.g. attr-ul-type
el.dataset.dfnType = 'element-attr';
let _for = fromIdToElement(m[1]);
// special casing usemap attribute
if (m[1] === "hyperlink" && m[2] === "usemap") {
_for = "img,object";
return;
}
if (m[1] === "aria") {
// reference to external defined elements, noexport
el.dataset.noexport = true;
return;
}
// "loading", "crossorigin", "autocapitalize" are used in middle position
// when describing possible keywords
if (["loading", "crossorigin", "autocapitalize"].includes(m[1])) {
el.dataset.dfnType = 'dfn';
// Not sure how to indicate this is for an attribute value
// _for = m[1];
}
if (_for && !el.dataset.dfnFor) {
el.dataset.dfnFor = _for;
}
return;
}

if ((m = el.id.match(/^dom-([^-]+)$/) || el.id.match(/^dom-([^-]+)-[0-9]+$/) || el.id.match(/^dom-([^-]+)-constructor$/))) {
const globalscopes = [
"ElementContentEditable",
Expand Down
10 changes: 0 additions & 10 deletions tests/extract-dfns.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,6 @@ const tests = [
}],
spec: "html"
},
{
title: "handles HTML spec convention for attributes",
html: '<dfn id="attr-html-manifest"><code>manifest</code></dfn>',
changesToBaseDfn: [{id: "attr-html-manifest",
access: "public",
type: "element-attr",
linkingText: ["manifest"],
for: ['html']}],
spec: "html"
},
{
title: "handles HTML spec convention for methods",
html: '<dfn id="dom-customelementregistry-whendefined"><code>whenDefined(<var>name</var>)</code></dfn>',
Expand Down