3134
3135
let children = null;
3136
let innerHTML = null;
3137
- for (let propKey in props) {
3137
+ for (const propKey in props) {
3138
if (hasOwnProperty.call(props, propKey)) {
3139
let propValue = props[propKey];
3140
if (propValue == null) {
3141
continue;
3142
}
3143
- if (
3144
- enableCustomElementPropertySupport &&
3145
- (typeof propValue === 'function' || typeof propValue === 'object')
3146
- ) {
3147
- // It is normal to render functions and objects on custom elements when
3148
- // client rendering, but when server rendering the output isn't useful,
3149
- // so skip it.
3150
- continue;
3151
- }
3152
- if (enableCustomElementPropertySupport && propValue === false) {
3153
- continue;
3154
- }
3155
- if (enableCustomElementPropertySupport && propValue === true) {
3156
- propValue = '';
3157
- }
3158
- if (enableCustomElementPropertySupport && propKey === 'className') {
3159
- // className gets rendered as class on the client, so it should be
3160
- // rendered as class on the server.
3161
- propKey = 'class';
3162
- }
3143
+ let attributeName = propKey;
3144
switch (propKey) {
3145
case 'children':
3146
children = propValue;
3155
case 'suppressHydrationWarning':
3156
// Ignored. These are built-in to React on the client.
3157
break;
3158
+ case 'className':
3159
+ if (enableCustomElementPropertySupport) {
3160
+ // className gets rendered as class on the client, so it should be
3161
+ // rendered as class on the server.
3162
+ attributeName = 'class';
3163
+ }
3164
+ // intentional fallthrough
3165
default:
3166
if (
3167
isAttributeNameSafe(propKey) &&
3168
typeof propValue !== 'function' &&
3169
typeof propValue !== 'symbol'
3170
) {
3171
+ if (enableCustomElementPropertySupport) {
3172
+ if (propValue === false) {
3173
+ continue;
3174
+ } else if (propValue === true) {
3175
+ propValue = '';
3176
+ } else if (typeof propValue === 'object') {
3177
+ continue;
3178
+ }
3179
+ }
3180
target.push(
3181
attributeSeparator,
3185
- stringToChunk(propKey),
3182
+ stringToChunk(attributeName),
3183
attributeAssign,
3184
stringToChunk(escapeTextForBrowser(propValue)),
3185
attributeEnd,