mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-03-29 09:08:32 +08:00
rename createNativeComponent to createReactDOMComponent
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* global window */
|
||||
import applyNativeMethods from '../../modules/applyNativeMethods'
|
||||
import createNativeComponent from '../../modules/createNativeComponent'
|
||||
import createReactDOMComponent from '../../modules/createReactDOMComponent'
|
||||
import ImageResizeMode from './ImageResizeMode'
|
||||
import ImageStylePropTypes from './ImageStylePropTypes'
|
||||
import resolveAssetSource from './resolveAssetSource'
|
||||
@@ -24,8 +24,8 @@ const ImageSourcePropType = PropTypes.oneOfType([
|
||||
|
||||
class Image extends Component {
|
||||
static propTypes = {
|
||||
accessibilityLabel: createNativeComponent.propTypes.accessibilityLabel,
|
||||
accessible: createNativeComponent.propTypes.accessible,
|
||||
accessibilityLabel: createReactDOMComponent.propTypes.accessibilityLabel,
|
||||
accessible: createReactDOMComponent.propTypes.accessible,
|
||||
children: PropTypes.any,
|
||||
defaultSource: ImageSourcePropType,
|
||||
onError: PropTypes.func,
|
||||
@@ -35,7 +35,7 @@ class Image extends Component {
|
||||
resizeMode: PropTypes.oneOf(['contain', 'cover', 'none', 'stretch']),
|
||||
source: ImageSourcePropType,
|
||||
style: StyleSheetPropType(ImageStylePropTypes),
|
||||
testID: createNativeComponent.propTypes.testID
|
||||
testID: createReactDOMComponent.propTypes.testID
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
@@ -116,7 +116,7 @@ class Image extends Component {
|
||||
]}
|
||||
testID={testID}
|
||||
>
|
||||
{createNativeComponent({ component: 'img', src: displayImage, style: styles.img })}
|
||||
{createReactDOMComponent({ component: 'img', src: displayImage, style: styles.img })}
|
||||
{children ? (
|
||||
<View children={children} pointerEvents='box-none' style={styles.children} />
|
||||
) : null}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import applyNativeMethods from '../../modules/applyNativeMethods'
|
||||
import createNativeComponent from '../../modules/createNativeComponent'
|
||||
import createReactDOMComponent from '../../modules/createReactDOMComponent'
|
||||
import { Component, PropTypes } from 'react'
|
||||
import StyleSheet from '../../apis/StyleSheet'
|
||||
import StyleSheetPropType from '../../apis/StyleSheet/StyleSheetPropType'
|
||||
@@ -7,14 +7,14 @@ import TextStylePropTypes from './TextStylePropTypes'
|
||||
|
||||
class Text extends Component {
|
||||
static propTypes = {
|
||||
accessibilityLabel: createNativeComponent.propTypes.accessibilityLabel,
|
||||
accessibilityRole: createNativeComponent.propTypes.accessibilityRole,
|
||||
accessible: createNativeComponent.propTypes.accessible,
|
||||
accessibilityLabel: createReactDOMComponent.propTypes.accessibilityLabel,
|
||||
accessibilityRole: createReactDOMComponent.propTypes.accessibilityRole,
|
||||
accessible: createReactDOMComponent.propTypes.accessible,
|
||||
children: PropTypes.any,
|
||||
numberOfLines: PropTypes.number,
|
||||
onPress: PropTypes.func,
|
||||
style: StyleSheetPropType(TextStylePropTypes),
|
||||
testID: createNativeComponent.propTypes.testID
|
||||
testID: createReactDOMComponent.propTypes.testID
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
@@ -35,7 +35,7 @@ class Text extends Component {
|
||||
...other
|
||||
} = this.props
|
||||
|
||||
return createNativeComponent({
|
||||
return createReactDOMComponent({
|
||||
...other,
|
||||
component: 'span',
|
||||
onClick: this._onPress,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import applyNativeMethods from '../../modules/applyNativeMethods'
|
||||
import createNativeComponent from '../../modules/createNativeComponent'
|
||||
import createReactDOMComponent from '../../modules/createReactDOMComponent'
|
||||
import omit from 'lodash/omit'
|
||||
import pick from 'lodash/pick'
|
||||
import React, { Component, PropTypes } from 'react'
|
||||
@@ -175,7 +175,7 @@ class TextInput extends Component {
|
||||
testID={testID}
|
||||
>
|
||||
<View style={styles.wrapper}>
|
||||
{createNativeComponent({ ...props, ref: 'input' })}
|
||||
{createReactDOMComponent({ ...props, ref: 'input' })}
|
||||
{optionalPlaceholder}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
/* eslint-env mocha */
|
||||
|
||||
import assert from 'assert'
|
||||
import createNativeComponent from '..'
|
||||
import createReactDOMComponent from '..'
|
||||
import { shallow } from 'enzyme'
|
||||
|
||||
suite('modules/createNativeComponent', () => {
|
||||
suite('modules/createReactDOMComponent', () => {
|
||||
test('prop "accessibilityLabel"', () => {
|
||||
const accessibilityLabel = 'accessibilityLabel'
|
||||
const element = shallow(createNativeComponent({ accessibilityLabel }))
|
||||
const element = shallow(createReactDOMComponent({ accessibilityLabel }))
|
||||
assert.equal(element.prop('aria-label'), accessibilityLabel)
|
||||
})
|
||||
|
||||
test('prop "accessibilityLiveRegion"', () => {
|
||||
const accessibilityLiveRegion = 'polite'
|
||||
const element = shallow(createNativeComponent({ accessibilityLiveRegion }))
|
||||
const element = shallow(createReactDOMComponent({ accessibilityLiveRegion }))
|
||||
assert.equal(element.prop('aria-live'), accessibilityLiveRegion)
|
||||
})
|
||||
|
||||
test('prop "accessibilityRole"', () => {
|
||||
const accessibilityRole = 'banner'
|
||||
let element = shallow(createNativeComponent({ accessibilityRole }))
|
||||
let element = shallow(createReactDOMComponent({ accessibilityRole }))
|
||||
assert.equal(element.prop('role'), accessibilityRole)
|
||||
assert.equal(element.is('header'), true)
|
||||
|
||||
const button = 'button'
|
||||
element = shallow(createNativeComponent({ accessibilityRole: 'button' }))
|
||||
element = shallow(createReactDOMComponent({ accessibilityRole: 'button' }))
|
||||
assert.equal(element.prop('type'), button)
|
||||
assert.equal(element.is('button'), true)
|
||||
})
|
||||
|
||||
test('prop "accessible"', () => {
|
||||
// accessible (implicit)
|
||||
let element = shallow(createNativeComponent({}))
|
||||
let element = shallow(createReactDOMComponent({}))
|
||||
assert.equal(element.prop('aria-hidden'), null)
|
||||
// accessible (explicit)
|
||||
element = shallow(createNativeComponent({ accessible: true }))
|
||||
element = shallow(createReactDOMComponent({ accessible: true }))
|
||||
assert.equal(element.prop('aria-hidden'), null)
|
||||
// not accessible
|
||||
element = shallow(createNativeComponent({ accessible: false }))
|
||||
element = shallow(createReactDOMComponent({ accessible: false }))
|
||||
assert.equal(element.prop('aria-hidden'), true)
|
||||
})
|
||||
|
||||
test('prop "component"', () => {
|
||||
const component = 'main'
|
||||
const element = shallow(createNativeComponent({ component }))
|
||||
const element = shallow(createReactDOMComponent({ component }))
|
||||
assert.equal(element.is('main'), true)
|
||||
})
|
||||
|
||||
test('prop "testID"', () => {
|
||||
// no testID
|
||||
let element = shallow(createNativeComponent({}))
|
||||
let element = shallow(createReactDOMComponent({}))
|
||||
assert.equal(element.prop('data-testid'), null)
|
||||
// with testID
|
||||
const testID = 'Example.testID'
|
||||
element = shallow(createNativeComponent({ testID }))
|
||||
element = shallow(createReactDOMComponent({ testID }))
|
||||
assert.equal(element.prop('data-testid'), testID)
|
||||
})
|
||||
})
|
||||
@@ -17,7 +17,7 @@ const roleComponents = {
|
||||
region: 'section'
|
||||
}
|
||||
|
||||
const createNativeComponent = ({
|
||||
const createReactDOMComponent = ({
|
||||
accessibilityLabel,
|
||||
accessibilityLiveRegion,
|
||||
accessibilityRole,
|
||||
@@ -43,7 +43,7 @@ const createNativeComponent = ({
|
||||
)
|
||||
}
|
||||
|
||||
createNativeComponent.propTypes = {
|
||||
createReactDOMComponent.propTypes = {
|
||||
accessibilityLabel: PropTypes.string,
|
||||
accessibilityLiveRegion: PropTypes.oneOf([ 'assertive', 'off', 'polite' ]),
|
||||
accessibilityRole: PropTypes.string,
|
||||
@@ -54,4 +54,4 @@ createNativeComponent.propTypes = {
|
||||
type: PropTypes.string
|
||||
}
|
||||
|
||||
module.exports = createNativeComponent
|
||||
module.exports = createReactDOMComponent
|
||||
Reference in New Issue
Block a user