Skip to content

Commit 13be9ec

Browse files
committed
Merge pull request #174 from plotly/moz-update-jan-2021
Update component gen process for recent MDN changes
1 parent a55ad4c commit 13be9ec

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: packages/dash-html-components/scripts/extract-attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const attributeMap = supportedAttributes.reduce((map, reactAttribute) => {
5555
* descriptions and supported elements.
5656
*/
5757
function extractAttributes($) {
58-
const $table = $('#Attribute_list').parent().find('table');
58+
const $table = $('#Attribute_list,#attribute_list').parent().find('table');
5959
if($table.length !== 1) {
6060
throw new Error('page structure changed at ' + htmlURL);
6161
}

Diff for: packages/dash-html-components/scripts/extract-elements.js

+11
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@ const request = require('request');
66

77
const refUrl = 'https://developer.mozilla.org/en-US/docs/Web/HTML/Element';
88
const dataPath = './data/elements.txt';
9+
const expectedElCount = 131;
910

1011
/**
1112
* From the MDN HTML elements reference, extract a list of elements.
1213
*/
1314
function extractElements($) {
1415
const excludeElements = [
1516
'html', 'head', 'body', 'style', 'h1–h6', 'input',
17+
// out of scope, different namespaces - but Mozilla added these to the
18+
// above reference page Jan 2021 so we need to exclude them now.
19+
// see https://github.com/mdn/content/pull/410
20+
'svg', 'math',
1621
// obsolete, non-standard, or deprecated tags
1722
'image', 'dir', 'tt', 'applet', 'noembed', 'bgsound', 'menu', 'menuitem',
1823
'noframes'
@@ -56,6 +61,12 @@ request(refUrl, (error, response, html) => {
5661
}
5762
const $ = cheerio.load(html);
5863
const elements = extractElements($);
64+
if (elements.length !== expectedElCount) {
65+
throw new Error(
66+
'Unexpected number of elements extracted from ' + refUrl +
67+
' Check the output and edit expectedElCount if this is intended.'
68+
);
69+
}
5970
const out = elements.join('\n');
6071

6172
fs.writeFileSync(dataPath, out);

0 commit comments

Comments
 (0)