(type, config, maybeKey)
| 280 | * @param {string} key |
| 281 | */ |
| 282 | export function jsxProd(type, config, maybeKey) { |
| 283 | let key = null; |
| 284 | |
| 285 | class="cm">// Currently, key can be spread in as a prop. This causes a potential |
| 286 | class="cm">// issue if key is also explicitly declared (ie. <div {...props} key=class="st">"Hi" /> |
| 287 | class="cm">// or <div key=class="st">"Hi" {...props} /> ). We want to deprecate key spread, |
| 288 | class="cm">// but as an intermediary step, we will use jsxDEV for everything except |
| 289 | class="cm">// <div {...props} key=class="st">"Hi" />, because we aren't currently able to tell if |
| 290 | class="cm">// key is explicitly declared to be undefined or not. |
| 291 | if (maybeKey !== undefined) { |
| 292 | if (__DEV__) { |
| 293 | checkKeyStringCoercion(maybeKey); |
| 294 | } |
| 295 | key = class="st">'' + maybeKey; |
| 296 | } |
| 297 | |
| 298 | if (hasValidKey(config)) { |
| 299 | if (__DEV__) { |
| 300 | checkKeyStringCoercion(config.key); |
| 301 | } |
| 302 | key = class="st">'' + config.key; |
| 303 | } |
| 304 | |
| 305 | let props; |
| 306 | if (!(class="st">'key' in config)) { |
| 307 | class="cm">// If key was not spread in, we can reuse the original props object. This |
| 308 | class="cm">// only works for `jsx`, not `createElement`, because `jsx` is a compiler |
| 309 | class="cm">// target and the compiler always passes a new object. For `createElement`, |
| 310 | class="cm">// we can't assume a new object is passed every time because it can be |
| 311 | class="cm">// called manually. |
| 312 | class="cm">// |
| 313 | class="cm">// Spreading key is a warning in dev. In a future release, we will not |
| 314 | class="cm">// remove a spread key from the props object. (But weclass="st">'ll still warn.) We'll |
| 315 | class="cm">// always pass the object straight through. |
| 316 | props = config; |
| 317 | } else { |
| 318 | class="cm">// We need to remove reserved props (key, prop, ref). Create a fresh props |
| 319 | class="cm">// object and copy over all the non-reserved props. We don't use `delete` |
| 320 | class="cm">// because in V8 it will deopt the object to dictionary mode. |
| 321 | props = {}; |
| 322 | for (const propName in config) { |
| 323 | class="cm">// Skip over reserved prop names |
| 324 | if (propName !== class="st">'key') { |
| 325 | props[propName] = config[propName]; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | return ReactElement(type, key, props, getOwner(), undefined, undefined); |
| 331 | } |
| 332 | |
| 333 | class="cm">// While `jsxDEV` should never be called when running in production, we do |
| 334 | class="cm">// support `jsx` and `jsxs` when running in development. This supports the case |
nothing calls this directly
no test coverage detected