mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Two minor changes from internal (#8855)
This commit is contained in:
@@ -465,7 +465,7 @@ var ReactDOMFiberComponent = {
|
||||
// Create the script via .innerHTML so its "parser-inserted" flag is
|
||||
// set to true and it does not execute
|
||||
var div = ownerDocument.createElement('div');
|
||||
div.innerHTML = '<script></script>';
|
||||
div.innerHTML = '<script><' + '/script>'; // eslint-disable-line
|
||||
// This is guaranteed to yield a script element.
|
||||
var firstChild = ((div.firstChild : any) : HTMLScriptElement);
|
||||
domElement = div.removeChild(firstChild);
|
||||
|
||||
@@ -16,25 +16,22 @@ import type { ReactInstance } from 'ReactInstanceType';
|
||||
import type { Fiber } from 'ReactFiber';
|
||||
|
||||
function getComponentName(instanceOrFiber : ReactInstance | Fiber) : string | null {
|
||||
if (__DEV__) {
|
||||
if (typeof instanceOrFiber.getName === 'function') {
|
||||
// Stack reconciler
|
||||
const instance = ((instanceOrFiber : any) : ReactInstance);
|
||||
return instance.getName() || 'Component';
|
||||
if (typeof instanceOrFiber.getName === 'function') {
|
||||
// Stack reconciler
|
||||
const instance = ((instanceOrFiber : any) : ReactInstance);
|
||||
return instance.getName() || 'Component';
|
||||
}
|
||||
if (typeof instanceOrFiber.tag === 'number') {
|
||||
// Fiber reconciler
|
||||
const fiber = ((instanceOrFiber : any) : Fiber);
|
||||
const {type} = fiber;
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
if (typeof instanceOrFiber.tag === 'number') {
|
||||
// Fiber reconciler
|
||||
const fiber = ((instanceOrFiber : any) : Fiber);
|
||||
const {type} = fiber;
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = getComponentName;
|
||||
|
||||
Reference in New Issue
Block a user