Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 33 additions & 0 deletions src/dom/attributes/BooleanAttributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* List of boolean attributes
* These attributes should have their React attribute value set to be the same as their name
* E.g. <input disabled> = <input disabled>
* <input disabled=""> = <input disabled>
* <input disabled="disabled"> = <input disabled>
* @type {Array}
*/
export default [
'allowfullScreen',
'async',
'autoplay',
'capture',
'checked',
'controls',
'default',
'defer',
'disabled',
'formnovalidate',
'hidden',
'loop',
'multiple',
'muted',
'novalidate',
'open',
'readonly',
'required',
'reversed',
'scoped',
'seamless',
'selected',
'itemscope'
];
158 changes: 158 additions & 0 deletions src/dom/attributes/ReactAttributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/**
* Mapping of standard HTML attributes to their React counterparts
* List taken and reversed from react/src/renderers/dom/shared/HTMLDOMPropertyConfig.js
* https://github.com/facebook/react/blob/c9c3c339b757682f1154f1c915eb55e6a8766933/src/renderers/dom/shared/HTMLDOMPropertyConfig.js
* @type {Object}
*/
export default {
/**
* Standard Properties
*/
accept: 'accept',
'accept-charset': 'acceptCharset',
accesskey: 'accessKey',
action: 'action',
allowfullscreen: 'allowFullScreen',
allowtransparency: 'allowTransparency',
alt: 'alt',
async: 'async',
autocomplete: 'autoComplete',
autoplay: 'autoPlay',
capture: 'capture',
cellpadding: 'cellPadding',
cellspacing: 'cellSpacing',
charset: 'charSet',
challenge: 'challenge',
checked: 'checked',
classid: 'classID',
class: 'className',
cols: 'cols',
colspan: 'colSpan',
content: 'content',
contenteditable: 'contentEditable',
contextmenu: 'contextMenu',
controls: 'controls',
coords: 'coords',
crossorigin: 'crossOrigin',
data: 'data',
datetime: 'dateTime',
default: 'default',
defer: 'defer',
dir: 'dir',
disabled: 'disabled',
download: 'download',
draggable: 'draggable',
enctype: 'encType',
form: 'form',
formaction: 'formAction',
formenctype: 'formEncType',
formmethod: 'formMethod',
formnovalidate: 'formNoValidate',
formtarget: 'formTarget',
frameborder: 'frameBorder',
headers: 'headers',
height: 'height',
hidden: 'hidden',
high: 'high',
href: 'href',
hreflang: 'hrefLang',
for: 'htmlFor',
'http-equiv': 'httpEquiv',
icon: 'icon',
id: 'id',
inputmode: 'inputMode',
integrity: 'integrity',
is: 'is',
keyparams: 'keyParams',
keytype: 'keyType',
kind: 'kind',
label: 'label',
lang: 'lang',
list: 'list',
loop: 'loop',
low: 'low',
manifest: 'manifest',
marginheight: 'marginHeight',
marginwidth: 'marginWidth',
max: 'max',
maxlength: 'maxLength',
media: 'media',
mediagroup: 'mediaGroup',
method: 'method',
min: 'min',
minlength: 'minLength',
multiple: 'multiple',
muted: 'muted',
name: 'name',
nonce: 'nonce',
novalidate: 'noValidate',
open: 'open',
optimum: 'optimum',
pattern: 'pattern',
placeholder: 'placeholder',
poster: 'poster',
preload: 'preload',
radiogroup: 'radioGroup',
readonly: 'readOnly',
rel: 'rel',
required: 'required',
reversed: 'reversed',
role: 'role',
rows: 'rows',
rowspan: 'rowSpan',
sandbox: 'sandbox',
scope: 'scope',
scoped: 'scoped',
scrolling: 'scrolling',
seamless: 'seamless',
selected: 'selected',
shape: 'shape',
size: 'size',
sizes: 'sizes',
span: 'span',
spellcheck: 'spellCheck',
src: 'src',
srcdoc: 'srcDoc',
srclang: 'srcLang',
srcset: 'srcSet',
start: 'start',
step: 'step',
style: 'style',
summary: 'summary',
tabindex: 'tabIndex',
target: 'target',
title: 'title',
type: 'type',
usemap: 'useMap',
value: 'value',
width: 'width',
wmode: 'wmode',
wrap: 'wrap',
/**
* RDFa Properties
*/
about: 'about',
datatype: 'datatype',
inlist: 'inlist',
prefix: 'prefix',
property: 'property',
resource: 'resource',
typeof: 'typeof',
vocab: 'vocab',
/**
* Non-standard Properties
*/
autocapitalize: 'autoCapitalize',
autocorrect: 'autoCorrect',
autosave: 'autoSave',
color: 'color',
itemprop: 'itemProp',
itemscope: 'itemScope',
itemtype: 'itemType',
itemid: 'itemID',
itemref: 'itemRef',
results: 'results',
security: 'security',
unselectable: 'unselectable',
autofocus: 'autoFocus'
};
13 changes: 6 additions & 7 deletions src/utils/isVoidElement.js → src/dom/elements/VoidElements.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
const voidElements = [
/**
* List of void elements
* These elements are not allowed to have children
* @type {Array}
*/
export default [
'area',
'base',
'br',
Expand All @@ -16,9 +21,3 @@ const voidElements = [
'track',
'wbr'
];

export default function isVoidElement(element) {

return voidElements.indexOf(element) >= 0;

}
4 changes: 2 additions & 2 deletions src/elementTypes/TagElementType.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ProcessNodes from '../utils/ProcessNodes';
import GeneratePropsFromAttributes from '../utils/GeneratePropsFromAttributes';
import TransformTagName from '../utils/TransformTagName';
import isVoidElement from '../utils/isVoidElement';
import VoidElements from '../dom/elements/VoidElements';

/**
* Converts any element (excluding style - see StyleElementType - and script) to a react element.
Expand All @@ -21,7 +21,7 @@ export default function TagElementType(node, key) {

// If the node is not a void element and has children then process them
let children = null;
if (!isVoidElement(tagName)) {
if (VoidElements.indexOf(tagName) === -1) {
children = ProcessNodes(node.children);
}

Expand Down
Loading