Skip to content

Commit

Permalink
Add hardcoded autoFocus to html attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Jul 25, 2023
1 parent fd50851 commit 9f9e4d2
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 47 deletions.
105 changes: 59 additions & 46 deletions components/dash-html-components/scripts/data/attributes.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"attributes": {
"autoFocus": {
"elements": [
"button",
"input",
"select",
"textarea"
],
"description": "The element should be automatically focused after the page loaded."
},
"accept": {
"elements": [
"form",
Expand Down Expand Up @@ -736,18 +745,21 @@
}
},
"elements": {
"form": [
"accept",
"acceptCharset",
"action",
"autoComplete",
"encType",
"method",
"button": [
"autoFocus",
"disabled",
"form",
"formAction",
"formEncType",
"formMethod",
"formNoValidate",
"formTarget",
"name",
"noValidate",
"target"
"type",
"value"
],
"input": [
"autoFocus",
"accept",
"alt",
"autoComplete",
Expand Down Expand Up @@ -780,6 +792,43 @@
"value",
"width"
],
"select": [
"autoFocus",
"autoComplete",
"disabled",
"form",
"multiple",
"name",
"required",
"size"
],
"textarea": [
"autoFocus",
"autoComplete",
"cols",
"disabled",
"form",
"inputMode",
"maxLength",
"minLength",
"name",
"placeholder",
"readOnly",
"required",
"rows",
"wrap"
],
"form": [
"accept",
"acceptCharset",
"action",
"autoComplete",
"encType",
"method",
"name",
"noValidate",
"target"
],
"Globalattribute": [
"accessKey",
"className",
Expand Down Expand Up @@ -836,30 +885,6 @@
"src",
"type"
],
"select": [
"autoComplete",
"disabled",
"form",
"multiple",
"name",
"required",
"size"
],
"textarea": [
"autoComplete",
"cols",
"disabled",
"form",
"inputMode",
"maxLength",
"minLength",
"name",
"placeholder",
"readOnly",
"required",
"rows",
"wrap"
],
"audio": [
"autoPlay",
"controls",
Expand Down Expand Up @@ -942,18 +967,6 @@
"src",
"srcLang"
],
"button": [
"disabled",
"form",
"formAction",
"formEncType",
"formMethod",
"formNoValidate",
"formTarget",
"name",
"type",
"value"
],
"fieldset": [
"disabled",
"form",
Expand Down Expand Up @@ -1067,4 +1080,4 @@
"value"
]
}
}
}
15 changes: 14 additions & 1 deletion components/dash-html-components/scripts/extract-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ const supportedAttributes = ['accept', 'accessKey', 'action', 'allow',
'srcDoc', 'srcLang', 'srcSet', 'start', 'step', 'style', 'summary', 'tabIndex',
'target', 'title', 'type', 'useMap', 'value', 'width', 'wmode', 'wrap'];


const hardcodedAttributes = {
autoFocus: {
elements: [
"button",
"input",
"select",
"textarea"
],
description: "The element should be automatically focused after the page loaded."
}
}

// Create a map of HTML attribute to React prop
// e.g. {"datetime": "dateTime"}
const attributeMap = supportedAttributes.reduce((map, reactAttribute) => {
Expand Down Expand Up @@ -58,7 +71,7 @@ function extractAttributes($) {
if($table.length !== 1) {
throw new Error('page structure changed at ' + htmlURL);
}
const attributes = {};
const attributes = hardcodedAttributes;

$table.find('tbody tr').each((i, row) => {
const $children = cheerio(row).find('td');
Expand Down

0 comments on commit 9f9e4d2

Please sign in to comment.