Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Block API: Update and dedupe attribute set
  • Loading branch information
aduth committed Mar 30, 2018
commit 7076f88269b4c134d73635420fd78ba433486cef
24 changes: 13 additions & 11 deletions blocks/api/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/;
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
*
* [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
* Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
* .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
* .map( ( tr ) => tr.firstChild.textContent.trim() )
* .reduce( ( result, tr ) => Object.assign( result, {
* [ tr.firstChild.textContent.trim() ]: true
* } ), {} ) ).sort();
*
* @type {Array}
*/
Expand All @@ -65,7 +67,6 @@ const BOOLEAN_ATTRIBUTES = [
'nomodule',
'novalidate',
'open',
'open',
'playsinline',
'readonly',
'required',
Expand All @@ -82,35 +83,36 @@ const BOOLEAN_ATTRIBUTES = [
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
*
* [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
* filter( ( tr ) => /("(.+?)";?\s*)+/.test( tr.lastChild.textContent ) )
* .map( ( tr ) => tr.firstChild.textContent.trim() )
* Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ]
* .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
* .reduce( ( result, tr ) => Object.assign( result, {
* [ tr.firstChild.textContent.trim() ]: true
* } ), {} ) ).sort();
*
* @type {Array}
*/
const ENUMERATED_ATTRIBUTES = [
'autocapitalize',
'autocomplete',
'charset',
'contenteditable',
'crossorigin',
'dir',
'decoding',
'dir',
'draggable',
'enctype',
'formenctype',
'formmethod',
'http-equiv',
'inputmode',
'kind',
'method',
'preload',
'sandbox',
'scope',
'shape',
'spellcheck',
'step',
'translate',
'type',
'type',
'workertype',
'wrap',
];

Expand Down