Skip to content

Commit

Permalink
Update attributes list with latest additions and removals from react …
Browse files Browse the repository at this point in the history
…attribute whitelist (#23)
  • Loading branch information
peternewnham authored Aug 9, 2017
1 parent 5eb31f2 commit 767f39b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
27 changes: 27 additions & 0 deletions scripts/attributes-diff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// this script diffs the react attribute whitelist with the one react html parser maintains
// to determine if it is out of date
// the build:lib task must have been run before this can work

const currentProperties = require('../lib/dom/attributes/ReactAttributes').default;
const reactProperties = require('react-dom/lib/HTMLDOMPropertyConfig').Properties;

const changes = {};

const currentKeys = Object.keys(currentProperties).map(key => currentProperties[key]);
const reactKeys = Object.keys(reactProperties);

// attributes that have been added to react
reactKeys.forEach(key => {
if (currentKeys.indexOf(key) === -1) {
changes[key] = 'add';
}
});

// attributes that have been removed from react
currentKeys.forEach(key => {
if (reactKeys.indexOf(key) === -1) {
changes[key] = 'remove';
}
});

console.log(changes); // eslint-disable-line no-console
1 change: 1 addition & 0 deletions src/dom/attributes/BooleanAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default [
'muted',
'novalidate',
'open',
'playsinline',
'readonly',
'required',
'reversed',
Expand Down
10 changes: 8 additions & 2 deletions src/dom/attributes/ReactAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
allowfullscreen: 'allowFullScreen',
allowtransparency: 'allowTransparency',
alt: 'alt',
as: 'as',
async: 'async',
autocomplete: 'autoComplete',
autoplay: 'autoPlay',
Expand All @@ -24,6 +25,7 @@ export default {
charset: 'charSet',
challenge: 'challenge',
checked: 'checked',
cite: 'cite',
classid: 'classID',
class: 'className',
cols: 'cols',
Expand All @@ -32,6 +34,7 @@ export default {
contenteditable: 'contentEditable',
contextmenu: 'contextMenu',
controls: 'controls',
controlsList: 'controlsList',
coords: 'coords',
crossorigin: 'crossOrigin',
data: 'data',
Expand Down Expand Up @@ -90,10 +93,13 @@ export default {
optimum: 'optimum',
pattern: 'pattern',
placeholder: 'placeholder',
playsinline: 'playsInline',
poster: 'poster',
preload: 'preload',
profile: 'profile',
radiogroup: 'radioGroup',
readonly: 'readOnly',
referrerpolicy: 'referrerPolicy',
rel: 'rel',
required: 'required',
reversed: 'reversed',
Expand All @@ -109,6 +115,7 @@ export default {
shape: 'shape',
size: 'size',
sizes: 'sizes',
slot: 'slot',
span: 'span',
spellcheck: 'spellCheck',
src: 'src',
Expand Down Expand Up @@ -153,6 +160,5 @@ export default {
itemref: 'itemRef',
results: 'results',
security: 'security',
unselectable: 'unselectable',
autofocus: 'autoFocus'
unselectable: 'unselectable'
};

0 comments on commit 767f39b

Please sign in to comment.