diff --git a/src/browserlib/extract-cssdfn.mjs b/src/browserlib/extract-cssdfn.mjs index 7b02da08..e61aa1a6 100644 --- a/src/browserlib/extract-cssdfn.mjs +++ b/src/browserlib/extract-cssdfn.mjs @@ -184,16 +184,25 @@ export default function () { } if (matchingValues.length === 0) { // Dangling production rule. That should never happen for properties, - // at-rules, descriptors and functions, since they should always be - // defined somewhere. That happens from time to time for types that are - // described in prose and that don't have a dfn. One could perhaps argue - // that these constructs ought to have a dfn too. - if (!res.warnings) { - res.warnings = [] + // at-rules, descriptors: they should always be defined somewhere. That + // happens from time to time for functions and types that are defined + // in a spec and (temporarily) extended in another spec. + if (rule.name.match(/^<.*>$/)) { + const isFunction = !!rule.name.match(/\(\)/); + res.values.push({ + name: isFunction ? rule.name.replace(/^<(.*)>$/, '$1') : rule.name, + type: isFunction ? 'function' : 'type', + value: rule.value + }); + } + else { + if (!res.warnings) { + res.warnings = []; + } + const warning = Object.assign({ msg: 'Missing definition' }, rule); + warnings.push(warning); + rootDfns.push(warning); } - const warning = Object.assign({ msg: 'Missing definition' }, rule); - warnings.push(warning); - rootDfns.push(warning); } } } diff --git a/test/extract-css.js b/test/extract-css.js index 8a9b76b5..5d399af6 100644 --- a/test/extract-css.js +++ b/test/extract-css.js @@ -1010,16 +1010,29 @@ that spans multiple lines */ ] }, + { + title: 'creates a definition when one is missing for a type', + html: ` +
<my-type> = none | auto+ `, + propertyName: 'values', + css: [{ + name: '
<my-type> = none | auto +foo = bar`, propertyName: 'warnings', css: [{ msg: 'Missing definition', - name: '', - value: 'none | auto' + name: 'foo', + value: 'bar' }] },