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

Find CSS properties that aren't in the tables #419

Merged
merged 4 commits into from
Oct 31, 2020
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
25 changes: 2 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
node_modules
config.json
.cache
reports/tr/crawl.json
reports/tr/css
reports/tr/dfns
reports/tr/idl
reports/tr/index.md
reports/tr/index.html
reports/tr/perissue.md
reports/tr/perissue.html
reports/tr/study.json
reports/tr/diff.md
reports/tr/diffnew.md
reports/tr/idl
reports/ed/crawl.json
reports/ed/css
reports/ed/dfns
reports/ed/index.md
reports/ed/index.html
reports/ed/perissue.md
reports/ed/perissue.html
reports/ed/study.json
reports/ed/diff.md
reports/ed/diffnew.md
reports/ed/idl
reports/*/*
!reports/*/README.md
9 changes: 1 addition & 8 deletions builds/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,7 @@
.map(dfn => dfn.name.split(',').map(name => Object.assign({},
dfn, { name: name.trim() })))
.reduce((acc, val) => acc.concat(val), [])
.forEach(dfn => {
if ((dfn.name === 'property-name') ||
(dfn.name === '--*')) {
// Ignore sample definition && custom properties definition
return;
}
res[dfn.name] = dfn;
});
.forEach(dfn => res[dfn.name] = dfn);
return res;
};

Expand Down
9 changes: 1 addition & 8 deletions src/browserlib/extract-cssdfn.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@ const extractDfns = (doc, selector, extractor) => {
.map(dfn => dfn.name.split(',').map(name => Object.assign({},
dfn, { name: name.trim() })))
.reduce((acc, val) => acc.concat(val), [])
.forEach(dfn => {
if ((dfn.name === 'property-name') ||
(dfn.name === '--*')) {
// Ignore sample definition && custom properties definition
return;
}
res[dfn.name] = dfn;
});
.forEach(dfn => res[dfn.name] = dfn);
return res;
};

Expand Down
59 changes: 42 additions & 17 deletions src/cli/crawl-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,55 @@ async function crawlSpec(spec, crawlOptions) {
result.idl = err;
}

// Add CSS property definitions that weren't in a table
(result.dfns || []).filter((dfn) => dfn.type == "property").forEach(propDfn => {
propDfn.linkingText.forEach(lt => {
if (!result.css.properties.hasOwnProperty(lt)) {
result.css.properties[lt] = {
name: lt
};
}
});
});

// Ideally, the sample definition (property-name) in CSS2 and the custom
// property definition (--*) in CSS Variables would not be flagged as
// real CSS properties. In practice, they are. Let's remove them from
// the extract.
['property-name', '--*'].forEach(prop => {
if ((result.css.properties || {})[prop]) {
delete result.css.properties[prop];
}
});

// Parse extracted CSS definitions
Object.keys(result.css.properties || {}).forEach(prop => {
try {
result.css.properties[prop].parsedValue = cssDfnParser.parsePropDefValue(
result.css.properties[prop].value || result.css.properties[prop].newValues);
} catch (e) {
result.css.properties[prop].valueParseError = e.message;
Object.entries(result.css.properties || {}).forEach(([prop, dfn]) => {
if (dfn.value || dfn.newValues) {
try {
dfn.parsedValue = cssDfnParser.parsePropDefValue(
dfn.value || dfn.newValues);
} catch (e) {
dfn.valueParseError = e.message;
}
}
});
Object.keys(result.css.descriptors || {}).forEach(desc => {
try {
result.css.descriptors[desc].parsedValue = cssDfnParser.parsePropDefValue(
result.css.descriptors[desc].value);
} catch (e) {
result.css.descriptors[desc].valueParseError = e.message;
Object.entries(result.css.descriptors || {}).forEach(([desc, dfn]) => {
if (dfn.value) {
try {
dfn.parsedValue = cssDfnParser.parsePropDefValue(
dfn.value);
} catch (e) {
dfn.valueParseError = e.message;
}
}
});
Object.keys(result.css.valuespaces || {}).forEach(vs => {
if (result.css.valuespaces[vs].value) {
Object.entries(result.css.valuespaces || {}).forEach(([vs, dfn]) => {
if (dfn.value) {
try {
result.css.valuespaces[vs].parsedValue = cssDfnParser.parsePropDefValue(
result.css.valuespaces[vs].value);
dfn.parsedValue = cssDfnParser.parsePropDefValue(
dfn.value);
} catch (e) {
result.css.valuespaces[vs].valueParseError = e.message;
dfn.valueParseError = e.message;
}
}
});
Expand Down