( target: Array<Chunk | PrecomputedChunk>, props: Object, formatContext: FormatContext, )
| 2129 | const selectedMarkerAttribute = stringToPrecomputedChunk(' selected=""'); |
| 2130 | |
| 2131 | function pushStartOption( |
| 2132 | target: Array<Chunk | PrecomputedChunk>, |
| 2133 | props: Object, |
| 2134 | formatContext: FormatContext, |
| 2135 | ): ReactNodeList { |
| 2136 | const selectedValue = formatContext.selectedValue; |
| 2137 | |
| 2138 | target.push(startChunkForTag('option')); |
| 2139 | |
| 2140 | let children = null; |
| 2141 | let value = null; |
| 2142 | let selected = null; |
| 2143 | let innerHTML = null; |
| 2144 | for (const propKey in props) { |
| 2145 | if (hasOwnProperty.call(props, propKey)) { |
| 2146 | const propValue = props[propKey]; |
| 2147 | if (propValue == null) { |
| 2148 | continue; |
| 2149 | } |
| 2150 | switch (propKey) { |
| 2151 | case 'children': |
| 2152 | children = propValue; |
| 2153 | break; |
| 2154 | case 'selected': |
| 2155 | // ignore |
| 2156 | selected = propValue; |
| 2157 | if (__DEV__) { |
| 2158 | // TODO: Remove support for `selected` in <option>. |
| 2159 | if (!didWarnSelectedSetOnOption) { |
| 2160 | console.error( |
| 2161 | 'Use the `defaultValue` or `value` props on <select> instead of ' + |
| 2162 | 'setting `selected` on <option>.', |
| 2163 | ); |
| 2164 | didWarnSelectedSetOnOption = true; |
| 2165 | } |
| 2166 | } |
| 2167 | break; |
| 2168 | case 'dangerouslySetInnerHTML': |
| 2169 | innerHTML = propValue; |
| 2170 | break; |
| 2171 | case 'value': |
| 2172 | value = propValue; |
| 2173 | // We intentionally fallthrough to also set the attribute on the node. |
| 2174 | default: |
| 2175 | pushAttribute(target, propKey, propValue); |
| 2176 | break; |
| 2177 | } |
| 2178 | } |
| 2179 | } |
| 2180 | |
| 2181 | if (selectedValue != null) { |
| 2182 | let stringValue; |
| 2183 | if (value !== null) { |
| 2184 | if (__DEV__) { |
| 2185 | checkAttributeStringCoercion(value, 'value'); |
| 2186 | } |
| 2187 | stringValue = '' + value; |
| 2188 | } else { |
no test coverage detected