mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
@@ -52,6 +52,17 @@ function getID(inst) {
|
||||
}
|
||||
}
|
||||
|
||||
function stripComplexValues(key, value) {
|
||||
if (typeof value !== 'object' || Array.isArray(value) || value == null) {
|
||||
return value;
|
||||
}
|
||||
var prototype = Object.getPrototypeOf(value);
|
||||
if (!prototype || prototype === Object.prototype) {
|
||||
return value;
|
||||
}
|
||||
return '<not serializable>';
|
||||
}
|
||||
|
||||
// This implementation of ReactPerf is going away some time mid 15.x.
|
||||
// While we plan to keep most of the API, the actual format of measurements
|
||||
// will change dramatically. To signal this, we wrap them into an opaque-ish
|
||||
@@ -174,7 +185,7 @@ var ReactDefaultPerf = {
|
||||
var result = {};
|
||||
result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
|
||||
result.type = item.type;
|
||||
result.args = JSON.stringify(item.args);
|
||||
result.args = JSON.stringify(item.args, stripComplexValues);
|
||||
return result;
|
||||
}));
|
||||
console.log(
|
||||
|
||||
@@ -237,6 +237,21 @@ describe('ReactDefaultPerf', function() {
|
||||
expect(summary).toEqual([]);
|
||||
});
|
||||
|
||||
it('should print a table after calling printOperations', function() {
|
||||
var container = document.createElement('div');
|
||||
var measurements = measure(() => {
|
||||
ReactDOM.render(<Div>hey</Div>, container);
|
||||
});
|
||||
spyOn(console, 'table');
|
||||
ReactDefaultPerf.printOperations(measurements);
|
||||
expect(console.table.calls.length).toBe(1);
|
||||
expect(console.table.argsForCall[0][0]).toEqual([{
|
||||
'data-reactid': '',
|
||||
type: 'set innerHTML',
|
||||
args: '{"node":"<not serializable>","children":[],"html":null,"text":null}',
|
||||
}]);
|
||||
});
|
||||
|
||||
it('warns once when using getMeasurementsSummaryMap', function() {
|
||||
var measurements = measure(() => {});
|
||||
spyOn(console, 'error');
|
||||
|
||||
Reference in New Issue
Block a user