MCPcopy Index your code
hub / github.com/react/react / pushStartOption

Function pushStartOption

packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js:2131–2230  ·  view source on GitHub ↗
(
  target: Array<Chunk | PrecomputedChunk>,
  props: Object,
  formatContext: FormatContext,
)

Source from the content-addressed store, hash-verified

2129const selectedMarkerAttribute = stringToPrecomputedChunk(' selected=""');
2130
2131function 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 {

Callers 1

pushStartInstanceFunction · 0.85

Calls 8

startChunkForTagFunction · 0.85
pushAttributeFunction · 0.85
flattenOptionChildrenFunction · 0.85
isArrayFunction · 0.85
pushInnerHTMLFunction · 0.85
pushMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected