Skip to content

Commit

Permalink
Hide behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed May 15, 2017
1 parent 01107b0 commit f1ef2cd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ describe('ReactElementValidator', () => {
);
});

it('provides stack via non-standard console.stack for invalid types', () => {
it('provides stack via non-standard console.__reactStack for invalid types', () => {
spyOn(console, 'error');

function Foo() {
Expand All @@ -539,8 +539,8 @@ describe('ReactElementValidator', () => {
}

try {
console.stack = jest.fn();
console.stackEnd = jest.fn();
console.__reactStack = jest.fn();
console.__reactStackEnd = jest.fn();

expect(() => {
ReactTestUtils.renderIntoDocument(React.createElement(App));
Expand All @@ -551,10 +551,10 @@ describe('ReactElementValidator', () => {
'defined in. Check the render method of `Foo`.',
);

expect(console.stack.mock.calls.length).toBe(1);
expect(console.stackEnd.mock.calls.length).toBe(1);
expect(console.__reactStack.mock.calls.length).toBe(1);
expect(console.__reactStackEnd.mock.calls.length).toBe(1);

var stack = console.stack.mock.calls[0][0];
var stack = console.__reactStack.mock.calls[0][0];
expect(Array.isArray(stack)).toBe(true);
expect(stack.map(frame => frame.name)).toEqual([
'Foo', // <Bad> is inside Foo
Expand All @@ -572,8 +572,8 @@ describe('ReactElementValidator', () => {
null,
]);
} finally {
delete console.stack;
delete console.stackEnd;
delete console.__reactStack;
delete console.__reactStackEnd;
}
});
});
8 changes: 4 additions & 4 deletions src/isomorphic/hooks/ReactComponentTreeHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ var ReactComponentTreeHook = {
isCreatingElement: boolean,
currentSource: ?Source,
) {
if (typeof console.stack !== 'function') {
if (typeof console.__reactStack !== 'function') {
return;
}

Expand Down Expand Up @@ -444,14 +444,14 @@ var ReactComponentTreeHook = {
// Stop building the stack (it's just a nice to have).
}

console.stack(stack);
console.__reactStack(stack);
},

popNonStandardWarningStack() {
if (typeof console.stackEnd !== 'function') {
if (typeof console.__reactStackEnd !== 'function') {
return;
}
console.stackEnd();
console.__reactStackEnd();
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ describe('ReactJSXElementValidator', () => {
);
});

it('provides stack via non-standard console.stack for invalid types', () => {
it('provides stack via non-standard console.__reactStack for invalid types', () => {
spyOn(console, 'error');

function Foo() {
Expand All @@ -414,8 +414,8 @@ describe('ReactJSXElementValidator', () => {
}

try {
console.stack = jest.fn();
console.stackEnd = jest.fn();
console.__reactStack = jest.fn();
console.__reactStackEnd = jest.fn();

expect(() => {
ReactTestUtils.renderIntoDocument(<App />);
Expand All @@ -426,10 +426,10 @@ describe('ReactJSXElementValidator', () => {
'defined in. Check the render method of `Foo`.',
);

expect(console.stack.mock.calls.length).toBe(1);
expect(console.stackEnd.mock.calls.length).toBe(1);
expect(console.__reactStack.mock.calls.length).toBe(1);
expect(console.__reactStackEnd.mock.calls.length).toBe(1);

var stack = console.stack.mock.calls[0][0];
var stack = console.__reactStack.mock.calls[0][0];
expect(Array.isArray(stack)).toBe(true);
expect(stack.map(frame => frame.name)).toEqual([
'Foo', // <Bad> is inside Foo
Expand All @@ -447,8 +447,8 @@ describe('ReactJSXElementValidator', () => {
'number',
]);
} finally {
delete console.stack;
delete console.stackEnd;
delete console.__reactStack;
delete console.__reactStackEnd;
}
});
});

0 comments on commit f1ef2cd

Please sign in to comment.