diff --git a/.gitignore b/.gitignore index b32bd32fb..cec4815ac 100644 --- a/.gitignore +++ b/.gitignore @@ -190,3 +190,4 @@ UpgradeLog*.htm # Microsoft Fakes FakesAssemblies/ +src/.idea diff --git a/src/React.Core/ReactEnvironment.cs b/src/React.Core/ReactEnvironment.cs index 9ec081d40..d7421846b 100644 --- a/src/React.Core/ReactEnvironment.cs +++ b/src/React.Core/ReactEnvironment.cs @@ -340,7 +340,7 @@ public virtual void GetInitJavaScript(TextWriter writer, bool clientOnly = false // Propagate any server-side console.log calls to corresponding client-side calls. if (!clientOnly && _components.Count != 0) { - var consoleCalls = Execute("console.getCalls()"); + var consoleCalls = Execute("console.drainCalls()"); writer.Write(consoleCalls); } diff --git a/src/React.Core/Resources/shims.js b/src/React.Core/Resources/shims.js index f99e4f264..b578e20b9 100644 --- a/src/React.Core/Resources/shims.js +++ b/src/React.Core/Resources/shims.js @@ -31,8 +31,10 @@ MockConsole.prototype = { _formatCall: function(call) { return 'console.' + call.method + '("[.NET]", ' + call.args.join(', ') + ', ' + JSON.stringify(call.stack) + ');'; }, - getCalls: function() { - return this._calls.map(this._formatCall).join('\n'); + drainCalls: function() { + var calls = this._calls.map(this._formatCall).join('\n'); + this._calls = []; + return calls; } }; var console = new MockConsole(); diff --git a/tests/React.Tests/Core/ReactEnvironmentTest.cs b/tests/React.Tests/Core/ReactEnvironmentTest.cs index 69ffb234d..371503166 100644 --- a/tests/React.Tests/Core/ReactEnvironmentTest.cs +++ b/tests/React.Tests/Core/ReactEnvironmentTest.cs @@ -187,7 +187,7 @@ public void SSRInitSkippedIfNoComponents(bool renderComponent, int ssrTimes) environment.GetInitJavaScript(); - mocks.Engine.Verify(x => x.Evaluate("console.getCalls()"), Times.Exactly(ssrTimes)); + mocks.Engine.Verify(x => x.Evaluate("console.drainCalls()"), Times.Exactly(ssrTimes)); } [Fact]