mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-23 14:57:13 +00:00
[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:
@@ -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)
|
||||
})
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ const createReactDOMComponent = ({
|
||||
accessibilityLiveRegion,
|
||||
accessibilityRole,
|
||||
accessible = true,
|
||||
component = 'div',
|
||||
component = 'span',
|
||||
testID,
|
||||
type,
|
||||
...other
|
||||
|
||||
Reference in New Issue
Block a user