aboutsummaryrefslogtreecommitdiff
path: root/node_modules/react/lib/ReactComponentTreeHook.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/react/lib/ReactComponentTreeHook.js
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/react/lib/ReactComponentTreeHook.js')
-rw-r--r--node_modules/react/lib/ReactComponentTreeHook.js53
1 files changed, 49 insertions, 4 deletions
diff --git a/node_modules/react/lib/ReactComponentTreeHook.js b/node_modules/react/lib/ReactComponentTreeHook.js
index b2faa205f..55eec6432 100644
--- a/node_modules/react/lib/ReactComponentTreeHook.js
+++ b/node_modules/react/lib/ReactComponentTreeHook.js
@@ -24,11 +24,11 @@ function isNative(fn) {
var hasOwnProperty = Object.prototype.hasOwnProperty;
var reIsNative = RegExp('^' + funcToString
// Take an example native function source for comparison
- .call(hasOwnProperty)
+ .call(hasOwnProperty
// Strip regex characters so we can use it for regex
- .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
+ ).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'
// Remove hasOwnProperty from the template to make it generic
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
+ ).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
try {
var source = funcToString.call(fn);
return reIsNative.test(source);
@@ -327,7 +327,52 @@ var ReactComponentTreeHook = {
getRootIDs: getRootIDs,
- getRegisteredIDs: getItemIDs
+ getRegisteredIDs: getItemIDs,
+
+ pushNonStandardWarningStack: function (isCreatingElement, currentSource) {
+ if (typeof console.reactStack !== 'function') {
+ return;
+ }
+
+ var stack = [];
+ var currentOwner = ReactCurrentOwner.current;
+ var id = currentOwner && currentOwner._debugID;
+
+ try {
+ if (isCreatingElement) {
+ stack.push({
+ name: id ? ReactComponentTreeHook.getDisplayName(id) : null,
+ fileName: currentSource ? currentSource.fileName : null,
+ lineNumber: currentSource ? currentSource.lineNumber : null
+ });
+ }
+
+ while (id) {
+ var element = ReactComponentTreeHook.getElement(id);
+ var parentID = ReactComponentTreeHook.getParentID(id);
+ var ownerID = ReactComponentTreeHook.getOwnerID(id);
+ var ownerName = ownerID ? ReactComponentTreeHook.getDisplayName(ownerID) : null;
+ var source = element && element._source;
+ stack.push({
+ name: ownerName,
+ fileName: source ? source.fileName : null,
+ lineNumber: source ? source.lineNumber : null
+ });
+ id = parentID;
+ }
+ } catch (err) {
+ // Internal state is messed up.
+ // Stop building the stack (it's just a nice to have).
+ }
+
+ console.reactStack(stack);
+ },
+ popNonStandardWarningStack: function () {
+ if (typeof console.reactStackEnd !== 'function') {
+ return;
+ }
+ console.reactStackEnd();
+ }
};
module.exports = ReactComponentTreeHook; \ No newline at end of file