Skip to content

Commit

Permalink
Make enableOwnerStacks dynamic (#31661)
Browse files Browse the repository at this point in the history
following up on #31287, fixing
tests

---------

Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>

DiffTrain build for [a496498](a496498)
  • Loading branch information
noahlemen committed Dec 11, 2024
1 parent 4e4144e commit 0bcbbf0
Show file tree
Hide file tree
Showing 37 changed files with 4,190 additions and 2,280 deletions.
88 changes: 78 additions & 10 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,21 @@ __DEV__ &&
}
return "";
}
function getTaskName(type) {
if (type === REACT_FRAGMENT_TYPE) return "<>";
if (
"object" === typeof type &&
null !== type &&
type.$$typeof === REACT_LAZY_TYPE
)
return "<...>";
try {
var name = getComponentNameFromType(type);
return name ? "<" + name + ">" : "<...>";
} catch (x) {
return "<...>";
}
}
function getOwner() {
var dispatcher = ReactSharedInternals.A;
return null === dispatcher ? null : dispatcher.getOwner();
Expand Down Expand Up @@ -409,7 +424,16 @@ __DEV__ &&
componentName = this.props.ref;
return void 0 !== componentName ? componentName : null;
}
function ReactElement(type, key, self, source, owner, props) {
function ReactElement(
type,
key,
self,
source,
owner,
props,
debugStack,
debugTask
) {
self = props.ref;
type = {
$$typeof: REACT_ELEMENT_TYPE,
Expand Down Expand Up @@ -437,6 +461,19 @@ __DEV__ &&
writable: !0,
value: null
});
enableOwnerStacks &&
(Object.defineProperty(type, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: debugStack
}),
Object.defineProperty(type, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: debugTask
}));
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
return type;
}
Expand All @@ -446,9 +483,12 @@ __DEV__ &&
maybeKey,
isStaticChildren,
source,
self
self,
debugStack,
debugTask
) {
if (
enableOwnerStacks ||
"string" === typeof type ||
"function" === typeof type ||
type === REACT_FRAGMENT_TYPE ||
Expand Down Expand Up @@ -562,10 +602,21 @@ __DEV__ &&
? type.displayName || type.name || "Unknown"
: type
);
return ReactElement(type, children, self, source, getOwner(), maybeKey);
return ReactElement(
type,
children,
self,
source,
getOwner(),
maybeKey,
debugStack,
debugTask
);
}
function validateChildKeys(node, parentType) {
if (
if (enableOwnerStacks)
isValidElement(node) && node._store && (node._store.validated = 1);
else if (
"object" === typeof node &&
node &&
node.$$typeof !== REACT_CLIENT_REFERENCE
Expand Down Expand Up @@ -601,6 +652,7 @@ __DEV__ &&
}
function validateExplicitKey(element, parentType) {
if (
!enableOwnerStacks &&
element._store &&
!element._store.validated &&
null == element.key &&
Expand Down Expand Up @@ -651,12 +703,13 @@ __DEV__ &&
dynamicFeatureFlags.disableDefaultPropsExceptForClasses,
enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing;
dynamicFeatureFlags = dynamicFeatureFlags.renameElementSymbol;
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_ELEMENT_TYPE = dynamicFeatureFlags
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
renameElementSymbol = dynamicFeatureFlags.renameElementSymbol,
enableOwnerStacks = dynamicFeatureFlags.enableOwnerStacks;
dynamicFeatureFlags = Symbol.for("react.element");
var REACT_ELEMENT_TYPE = renameElementSymbol
? Symbol.for("react.transitional.element")
: REACT_LEGACY_ELEMENT_TYPE,
: dynamicFeatureFlags,
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
Expand Down Expand Up @@ -699,6 +752,12 @@ __DEV__ &&
"function" === typeof WeakMap ? WeakMap : Map
)();
var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
createTask =
enableOwnerStacks && console.createTask
? console.createTask
: function () {
return null;
},
specialPropKeyWarningShown;
var didWarnAboutElementRef = {};
var didWarnAboutKeySpread = {},
Expand All @@ -712,6 +771,15 @@ __DEV__ &&
source,
self
) {
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
return jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
enableOwnerStacks ? Error("react-stack-top-frame") : void 0,
enableOwnerStacks ? createTask(getTaskName(type)) : void 0
);
};
})();
88 changes: 78 additions & 10 deletions compiled/facebook-www/JSXDEVRuntime-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,21 @@ __DEV__ &&
}
return "";
}
function getTaskName(type) {
if (type === REACT_FRAGMENT_TYPE) return "<>";
if (
"object" === typeof type &&
null !== type &&
type.$$typeof === REACT_LAZY_TYPE
)
return "<...>";
try {
var name = getComponentNameFromType(type);
return name ? "<" + name + ">" : "<...>";
} catch (x) {
return "<...>";
}
}
function getOwner() {
var dispatcher = ReactSharedInternals.A;
return null === dispatcher ? null : dispatcher.getOwner();
Expand Down Expand Up @@ -409,7 +424,16 @@ __DEV__ &&
componentName = this.props.ref;
return void 0 !== componentName ? componentName : null;
}
function ReactElement(type, key, self, source, owner, props) {
function ReactElement(
type,
key,
self,
source,
owner,
props,
debugStack,
debugTask
) {
self = props.ref;
type = {
$$typeof: REACT_ELEMENT_TYPE,
Expand Down Expand Up @@ -437,6 +461,19 @@ __DEV__ &&
writable: !0,
value: null
});
enableOwnerStacks &&
(Object.defineProperty(type, "_debugStack", {
configurable: !1,
enumerable: !1,
writable: !0,
value: debugStack
}),
Object.defineProperty(type, "_debugTask", {
configurable: !1,
enumerable: !1,
writable: !0,
value: debugTask
}));
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
return type;
}
Expand All @@ -446,9 +483,12 @@ __DEV__ &&
maybeKey,
isStaticChildren,
source,
self
self,
debugStack,
debugTask
) {
if (
enableOwnerStacks ||
"string" === typeof type ||
"function" === typeof type ||
type === REACT_FRAGMENT_TYPE ||
Expand Down Expand Up @@ -562,10 +602,21 @@ __DEV__ &&
? type.displayName || type.name || "Unknown"
: type
);
return ReactElement(type, children, self, source, getOwner(), maybeKey);
return ReactElement(
type,
children,
self,
source,
getOwner(),
maybeKey,
debugStack,
debugTask
);
}
function validateChildKeys(node, parentType) {
if (
if (enableOwnerStacks)
isValidElement(node) && node._store && (node._store.validated = 1);
else if (
"object" === typeof node &&
node &&
node.$$typeof !== REACT_CLIENT_REFERENCE
Expand Down Expand Up @@ -601,6 +652,7 @@ __DEV__ &&
}
function validateExplicitKey(element, parentType) {
if (
!enableOwnerStacks &&
element._store &&
!element._store.validated &&
null == element.key &&
Expand Down Expand Up @@ -651,12 +703,13 @@ __DEV__ &&
dynamicFeatureFlags.disableDefaultPropsExceptForClasses,
enableDebugTracing = dynamicFeatureFlags.enableDebugTracing,
enableRenderableContext = dynamicFeatureFlags.enableRenderableContext,
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing;
dynamicFeatureFlags = dynamicFeatureFlags.renameElementSymbol;
var REACT_LEGACY_ELEMENT_TYPE = Symbol.for("react.element"),
REACT_ELEMENT_TYPE = dynamicFeatureFlags
enableTransitionTracing = dynamicFeatureFlags.enableTransitionTracing,
renameElementSymbol = dynamicFeatureFlags.renameElementSymbol,
enableOwnerStacks = dynamicFeatureFlags.enableOwnerStacks;
dynamicFeatureFlags = Symbol.for("react.element");
var REACT_ELEMENT_TYPE = renameElementSymbol
? Symbol.for("react.transitional.element")
: REACT_LEGACY_ELEMENT_TYPE,
: dynamicFeatureFlags,
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
Expand Down Expand Up @@ -699,6 +752,12 @@ __DEV__ &&
"function" === typeof WeakMap ? WeakMap : Map
)();
var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
createTask =
enableOwnerStacks && console.createTask
? console.createTask
: function () {
return null;
},
specialPropKeyWarningShown;
var didWarnAboutElementRef = {};
var didWarnAboutKeySpread = {},
Expand All @@ -712,6 +771,15 @@ __DEV__ &&
source,
self
) {
return jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self);
return jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
enableOwnerStacks ? Error("react-stack-top-frame") : void 0,
enableOwnerStacks ? createTask(getTaskName(type)) : void 0
);
};
})();
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7c4a7c9ddf2f1c8e223565af1256ea201ec0f303
a4964987dc140526702e996223fe7ee293def8ac
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7c4a7c9ddf2f1c8e223565af1256ea201ec0f303
a4964987dc140526702e996223fe7ee293def8ac
Loading

0 comments on commit 0bcbbf0

Please sign in to comment.