( target: Array<Chunk | PrecomputedChunk>, props: Object, formatContext: FormatContext, )
| 2036 | } |
| 2037 | |
| 2038 | function pushStartSelect( |
| 2039 | target: Array<Chunk | PrecomputedChunk>, |
| 2040 | props: Object, |
| 2041 | formatContext: FormatContext, |
| 2042 | ): ReactNodeList { |
| 2043 | if (__DEV__) { |
| 2044 | checkControlledValueProps('select', props); |
| 2045 | |
| 2046 | checkSelectProp(props, 'value'); |
| 2047 | checkSelectProp(props, 'defaultValue'); |
| 2048 | |
| 2049 | if ( |
| 2050 | props.value !== undefined && |
| 2051 | props.defaultValue !== undefined && |
| 2052 | !didWarnDefaultSelectValue |
| 2053 | ) { |
| 2054 | console.error( |
| 2055 | 'Select elements must be either controlled or uncontrolled ' + |
| 2056 | '(specify either the value prop, or the defaultValue prop, but not ' + |
| 2057 | 'both). Decide between using a controlled or uncontrolled select ' + |
| 2058 | 'element and remove one of these props. More info: ' + |
| 2059 | 'https://react.dev/link/controlled-components', |
| 2060 | ); |
| 2061 | didWarnDefaultSelectValue = true; |
| 2062 | } |
| 2063 | } |
| 2064 | |
| 2065 | target.push(startChunkForTag('select')); |
| 2066 | |
| 2067 | let children = null; |
| 2068 | let innerHTML = null; |
| 2069 | for (const propKey in props) { |
| 2070 | if (hasOwnProperty.call(props, propKey)) { |
| 2071 | const propValue = props[propKey]; |
| 2072 | if (propValue == null) { |
| 2073 | continue; |
| 2074 | } |
| 2075 | switch (propKey) { |
| 2076 | case 'children': |
| 2077 | children = propValue; |
| 2078 | break; |
| 2079 | case 'dangerouslySetInnerHTML': |
| 2080 | // TODO: This doesn't really make sense for select since it can't use the controlled |
| 2081 | // value in the innerHTML. |
| 2082 | innerHTML = propValue; |
| 2083 | break; |
| 2084 | case 'defaultValue': |
| 2085 | case 'value': |
| 2086 | // These are set on the Context instead and applied to the nested options. |
| 2087 | break; |
| 2088 | default: |
| 2089 | pushAttribute(target, propKey, propValue); |
| 2090 | break; |
| 2091 | } |
| 2092 | } |
| 2093 | } |
| 2094 | |
| 2095 | pushViewTransitionAttributes(target, formatContext); |
no test coverage detected