[fix] default DOM element for 'View'

There are certain contexts where using a `div` is invalid HTML and may
cause rendering issues. Change the default element created by
`createReactDOMComponent` to a `span`.

**Appendix**

The following HTML results a validator error.

  <!DOCTYPE html>
  <head>
  <meta charset="utf-8">
  <title>test</title>
  <button><div>a</div></button>

Error: Element `div` not allowed as child of element `button` in this
context.

Source: https://validator.w3.org/nu/#textarea
This commit is contained in:
Nicolas Gallagher
2016-07-11 20:25:05 -07:00
parent 640e41dc34
commit 41159bcb10
2 changed files with 4 additions and 2 deletions
@@ -43,7 +43,9 @@ suite('modules/createReactDOMComponent', () => {
test('prop "component"', () => {
const component = 'main'
const element = shallow(createReactDOMComponent({ component }))
let element = shallow(createReactDOMComponent({}))
assert.equal(element.is('span'), true, 'Default element must be a "span"')
element = shallow(createReactDOMComponent({ component }))
assert.equal(element.is('main'), true)
})
+1 -1
View File
@@ -22,7 +22,7 @@ const createReactDOMComponent = ({
accessibilityLiveRegion,
accessibilityRole,
accessible = true,
component = 'div',
component = 'span',
testID,
type,
...other