Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onopentag: function (name, attribs){
if(bcd.html.elements[name]){
Object.keys(browserScope).map((browser)=>{
let versionAddedElem;
if(bcd.html.elements[name].__compat.support[browser]){
versionAddedElem = bcd.html.elements[name].__compat.support[browser].version_added;
}
if((versionAddedElem !== null) && ((!versionAddedElem) || (versionAddedElem !== true && semver.lt(semver.coerce(browserScope[browser]), semver.coerce(versionAddedElem)) ))){
report.push({
"featureName":"<" + name + ">",
"browser":browser,
"fileName":fileName,
"line": numLine,
"column": 0,
"featureVersion":versionAddedElem
});
}
// Intercept any feature that isn't properly filled into MDN according to
// browsers: compatData.browsers,
// css: compatData.css,
// html: compatData.html,
// http: compatData.http,
// javascript: compatData.javascript,
// mathml: compatData.mathml,
// svg: compatData.svg,
// webdriver: compatData.webdriver,
// webextensions: compatData.webextensions
// }
const payload = {
api: compatData.api,
browsers: compatData.browsers,
css: compatData.css,
html: compatData.html,
http: compatData.http,
javascript: compatData.javascript,
mathml: compatData.mathml,
svg: compatData.svg,
webdriver: compatData.webdriver,
webextensions: compatData.webextensions
}
fs.writeFile(
path.resolve(
__dirname,
'..',
'public',
'data.json'
),
JSON.stringify(payload, null, 2),
* Strip browser details down to name only.
*
* @param {bcd.Browsers} browsers
*/
const removeBrowserDetails = (browsers) => {
for (const browserName of Object.keys(browsers)) {
browsers[browserName] = /** @type {any} */({ name: browsers[browserName].name });
}
};
// Remove unnecessary data
const data = {
browsers: mdn.browsers,
css: mdn.css,
html: mdn.html
};
// TODO: drop `browsers` after `hint-compat-api` uses new util methods.
removeBrowserDetails(data.browsers);
removeFeatures(data.css);
removeFeatures(data.html);
const code = `/* eslint-disable */
import { Browsers, PrimaryIdentifier } from 'mdn-browser-compat-data/types';
type Data = {
browsers: Browsers;
css: PrimaryIdentifier;
html: PrimaryIdentifier;
}
Object.keys(attribs).map((attrib)=>{
let versionAddedAttr;
let featureName = "";
if(bcd.html.elements[name][attrib] && bcd.html.elements[name][attrib].__compat && bcd.html.elements[name][attrib].__compat.support[browser]){
versionAddedAttr = bcd.html.elements[name][attrib].__compat.support[browser].version_added;
featureName = "<" + name + "> - attribute " + attrib;
} else if (bcd.html.global_attributes[attrib] && bcd.html.global_attributes[attrib].__compat && bcd.html.global_attributes[attrib].__compat.support[browser]){
versionAddedAttr = bcd.html.global_attributes[attrib].__compat.support[browser].version_added;
featureName = "global attribute " + attrib;
}
if(versionAddedAttr !== undefined && versionAddedAttr !== null){
if((!versionAddedAttr) || (versionAddedAttr !== true && semver.lt(semver.coerce(browserScope[browser]), semver.coerce(versionAddedAttr)) )){
report.push({
"featureName":featureName,
"browser":browser,
"fileName":fileName,
"line": numLine,
"column": 0,
"featureVersion":versionAddedAttr
});
}
}
if((options.contrib === "true" || options.contrib === "all" ) && versionAddedAttr === true){
}
t.references.push({
name: 'MDN Reference',
url: bcdMatchingTag.__compat.mdn_url
})
}
}
})
/*---------------------------------------------------------------------------------------------
* Global Attributes
*--------------------------------------------------------------------------------------------*/
const htmlGlobalAttributes = require('./htmlGlobalAttributes.json')
const bcdGlobalAttributes = bcd.html.global_attributes
htmlGlobalAttributes.forEach(a => {
if (a.description) {
a.description = {
kind: 'markdown',
value: a.description
}
}
if (
bcdGlobalAttributes[a.name] &&
bcdGlobalAttributes[a.name].__compat &&
bcdGlobalAttributes[a.name].__compat.mdn_url
) {
if (!a.references) {
a.references = []
}
}
})
t.attributes = t.attributes.concat(moreAttrs)
}
})
htmlTags.forEach(t => {
if (t.description) {
t.description = {
kind: 'markdown',
value: t.description
}
}
})
const bcdHTMLElements = bcd.html.elements
htmlTags.forEach(t => {
if (bcdHTMLElements[t.name]) {
const bcdMatchingTag = bcdHTMLElements[t.name]
if (bcdMatchingTag.__compat && bcdMatchingTag.__compat.mdn_url) {
if (!t.references) {
t.references = []
}
t.references.push({
name: 'MDN Reference',
url: bcdMatchingTag.__compat.mdn_url
})
}
}
})
/*---------------------------------------------------------------------------------------------