@samitouri / QOS-React / commits / 81f554817c

renamed methods (devtool -> hook)

Keyan Zhang committed Jul 29, 2016 at 16:11 UTC 81f554817cc19ba7fdcac3dbeb2ae8f980fea922
8 files changed +44 -44
src/isomorphic/hooks/ReactComponentTreeHook.js
+1 -1
@@ -86,7 +86,7 @@ var ReactComponentTreeHook = {
86 var nextChild = tree[nextChildID];
87 invariant(
88 nextChild,
89 - 'Expected devtool events to fire for the child ' +
89 + 'Expected hook events to fire for the child ' +
90 'before its parent includes it in onSetChildren().'
91 );
92 invariant(
src/renderers/dom/client/ReactMount.js
+1 -1
@@ -302,7 +302,7 @@ var ReactMount = {
302 },
303
304 /**
305 - * Render a new component into the DOM. Hooked by devtools!
305 + * Render a new component into the DOM. Hooked by hooks!
306 *
307 * @param {ReactElement} nextElement element to render
308 * @param {DOMElement} container container to render into
src/renderers/dom/shared/ReactDOMDebugTool.js
+9 -9
@@ -29,7 +29,7 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
29 } catch (e) {
30 warning(
31 handlerDoesThrowForEvent[handlerFunctionName],
32 - 'exception thrown by devtool while handling %s: %s',
32 + 'exception thrown by hook while handling %s: %s',
33 handlerFunctionName,
34 e + '\n' + e.stack
35 );
@@ -39,14 +39,14 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
39 }
40
41 var ReactDOMDebugTool = {
42 - addDevtool(devtool) {
43 - ReactDebugTool.addDevtool(devtool);
44 - eventHandlers.push(devtool);
42 + addHook(hook) {
43 + ReactDebugTool.addHook(hook);
44 + eventHandlers.push(hook);
45 },
46 - removeDevtool(devtool) {
47 - ReactDebugTool.removeDevtool(devtool);
46 + removeHook(hook) {
47 + ReactDebugTool.removeHook(hook);
48 for (var i = 0; i < eventHandlers.length; i++) {
49 - if (eventHandlers[i] === devtool) {
49 + if (eventHandlers[i] === hook) {
50 eventHandlers.splice(i, 1);
51 i--;
52 }
@@ -66,7 +66,7 @@ var ReactDOMDebugTool = {
66 },
67 };
68
69 -ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyHook);
70 -ReactDOMDebugTool.addDevtool(ReactDOMNullInputValuePropHook);
69 +ReactDOMDebugTool.addHook(ReactDOMUnknownPropertyHook);
70 +ReactDOMDebugTool.addHook(ReactDOMNullInputValuePropHook);
71
72 module.exports = ReactDOMDebugTool;
src/renderers/dom/shared/__tests__/ReactDOMDebugTool-test.js
+10 -10
@@ -19,13 +19,13 @@ describe('ReactDOMDebugTool', function() {
19 ReactDOMDebugTool = require('ReactDOMDebugTool');
20 });
21
22 - it('should add and remove devtools', () => {
22 + it('should add and remove hooks', () => {
23 var handler1 = jasmine.createSpy('spy');
24 var handler2 = jasmine.createSpy('spy');
25 - var devtool1 = {onTestEvent: handler1};
26 - var devtool2 = {onTestEvent: handler2};
25 + var hook1 = {onTestEvent: handler1};
26 + var hook2 = {onTestEvent: handler2};
27
28 - ReactDOMDebugTool.addDevtool(devtool1);
28 + ReactDOMDebugTool.addHook(hook1);
29 ReactDOMDebugTool.onTestEvent();
30 expect(handler1.calls.count()).toBe(1);
31 expect(handler2.calls.count()).toBe(0);
@@ -34,7 +34,7 @@ describe('ReactDOMDebugTool', function() {
34 expect(handler1.calls.count()).toBe(2);
35 expect(handler2.calls.count()).toBe(0);
36
37 - ReactDOMDebugTool.addDevtool(devtool2);
37 + ReactDOMDebugTool.addHook(hook2);
38 ReactDOMDebugTool.onTestEvent();
39 expect(handler1.calls.count()).toBe(3);
40 expect(handler2.calls.count()).toBe(1);
@@ -43,20 +43,20 @@ describe('ReactDOMDebugTool', function() {
43 expect(handler1.calls.count()).toBe(4);
44 expect(handler2.calls.count()).toBe(2);
45
46 - ReactDOMDebugTool.removeDevtool(devtool1);
46 + ReactDOMDebugTool.removeHook(hook1);
47 ReactDOMDebugTool.onTestEvent();
48 expect(handler1.calls.count()).toBe(4);
49 expect(handler2.calls.count()).toBe(3);
50
51 - ReactDOMDebugTool.removeDevtool(devtool2);
51 + ReactDOMDebugTool.removeHook(hook2);
52 ReactDOMDebugTool.onTestEvent();
53 expect(handler1.calls.count()).toBe(4);
54 expect(handler2.calls.count()).toBe(3);
55 });
56
57 - it('warns once when an error is thrown in devtool', () => {
57 + it('warns once when an error is thrown in hook', () => {
58 spyOn(console, 'error');
59 - ReactDOMDebugTool.addDevtool({
59 + ReactDOMDebugTool.addHook({
60 onTestEvent() {
61 throw new Error('Hi.');
62 },
@@ -65,7 +65,7 @@ describe('ReactDOMDebugTool', function() {
65 ReactDOMDebugTool.onTestEvent();
66 expect(console.error.calls.count()).toBe(1);
67 expect(console.error.calls.argsFor(0)[0]).toContain(
68 - 'exception thrown by devtool while handling ' +
68 + 'exception thrown by hook while handling ' +
69 'onTestEvent: Error: Hi.'
70 );
71
src/renderers/shared/ReactDebugTool.js
+10 -10
@@ -32,7 +32,7 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
32 } catch (e) {
33 warning(
34 handlerDoesThrowForEvent[handlerFunctionName],
35 - 'exception thrown by devtool while handling %s: %s',
35 + 'exception thrown by hook while handling %s: %s',
36 handlerFunctionName,
37 e + '\n' + e.stack
38 );
@@ -182,12 +182,12 @@ function resumeCurrentLifeCycleTimer() {
182 }
183
184 var ReactDebugTool = {
185 - addDevtool(devtool) {
186 - eventHandlers.push(devtool);
185 + addHook(hook) {
186 + eventHandlers.push(hook);
187 },
188 - removeDevtool(devtool) {
188 + removeHook(hook) {
189 for (var i = 0; i < eventHandlers.length; i++) {
190 - if (eventHandlers[i] === devtool) {
190 + if (eventHandlers[i] === hook) {
191 eventHandlers.splice(i, 1);
192 i--;
193 }
@@ -204,7 +204,7 @@ var ReactDebugTool = {
204 isProfiling = true;
205 flushHistory.length = 0;
206 resetMeasurements();
207 - ReactDebugTool.addDevtool(ReactHostOperationHistoryHook);
207 + ReactDebugTool.addHook(ReactHostOperationHistoryHook);
208 },
209 endProfiling() {
210 if (!isProfiling) {
@@ -213,7 +213,7 @@ var ReactDebugTool = {
213
214 isProfiling = false;
215 resetMeasurements();
216 - ReactDebugTool.removeDevtool(ReactHostOperationHistoryHook);
216 + ReactDebugTool.removeHook(ReactHostOperationHistoryHook);
217 },
218 getFlushHistory() {
219 return flushHistory;
@@ -325,9 +325,9 @@ var ReactDebugTool = {
325 },
326 };
327
328 -ReactDebugTool.addDevtool(ReactInvalidSetStateWarningHook);
329 -ReactDebugTool.addDevtool(ReactComponentTreeHook);
330 -ReactDebugTool.addDevtool(ReactChildrenMutationWarningHook);
328 +ReactDebugTool.addHook(ReactInvalidSetStateWarningHook);
329 +ReactDebugTool.addHook(ReactComponentTreeHook);
330 +ReactDebugTool.addHook(ReactChildrenMutationWarningHook);
331 var url = (ExecutionEnvironment.canUseDOM && window.location.href) || '';
332 if ((/[?&]react_perf\b/).test(url)) {
333 ReactDebugTool.beginProfiling();
src/renderers/shared/__tests__/ReactDebugTool-test.js
+10 -10
@@ -19,13 +19,13 @@ describe('ReactDebugTool', function() {
19 ReactDebugTool = require('ReactDebugTool');
20 });
21
22 - it('should add and remove devtools', () => {
22 + it('should add and remove hooks', () => {
23 var handler1 = jasmine.createSpy('spy');
24 var handler2 = jasmine.createSpy('spy');
25 - var devtool1 = {onTestEvent: handler1};
26 - var devtool2 = {onTestEvent: handler2};
25 + var hook1 = {onTestEvent: handler1};
26 + var hook2 = {onTestEvent: handler2};
27
28 - ReactDebugTool.addDevtool(devtool1);
28 + ReactDebugTool.addHook(hook1);
29 ReactDebugTool.onTestEvent();
30 expect(handler1.calls.count()).toBe(1);
31 expect(handler2.calls.count()).toBe(0);
@@ -34,7 +34,7 @@ describe('ReactDebugTool', function() {
34 expect(handler1.calls.count()).toBe(2);
35 expect(handler2.calls.count()).toBe(0);
36
37 - ReactDebugTool.addDevtool(devtool2);
37 + ReactDebugTool.addHook(hook2);
38 ReactDebugTool.onTestEvent();
39 expect(handler1.calls.count()).toBe(3);
40 expect(handler2.calls.count()).toBe(1);
@@ -43,20 +43,20 @@ describe('ReactDebugTool', function() {
43 expect(handler1.calls.count()).toBe(4);
44 expect(handler2.calls.count()).toBe(2);
45
46 - ReactDebugTool.removeDevtool(devtool1);
46 + ReactDebugTool.removeHook(hook1);
47 ReactDebugTool.onTestEvent();
48 expect(handler1.calls.count()).toBe(4);
49 expect(handler2.calls.count()).toBe(3);
50
51 - ReactDebugTool.removeDevtool(devtool2);
51 + ReactDebugTool.removeHook(hook2);
52 ReactDebugTool.onTestEvent();
53 expect(handler1.calls.count()).toBe(4);
54 expect(handler2.calls.count()).toBe(3);
55 });
56
57 - it('warns once when an error is thrown in devtool', () => {
57 + it('warns once when an error is thrown in hook', () => {
58 spyOn(console, 'error');
59 - ReactDebugTool.addDevtool({
59 + ReactDebugTool.addHook({
60 onTestEvent() {
61 throw new Error('Hi.');
62 },
@@ -65,7 +65,7 @@ describe('ReactDebugTool', function() {
65 ReactDebugTool.onTestEvent();
66 expect(console.error.calls.count()).toBe(1);
67 expect(console.error.calls.argsFor(0)[0]).toContain(
68 - 'exception thrown by devtool while handling ' +
68 + 'exception thrown by hook while handling ' +
69 'onTestEvent: Error: Hi.'
70 );
71
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
+1 -1
@@ -87,7 +87,7 @@ describe('ReactComponentTreeHook', () => {
87 ReactDOMServer.renderToString(<Wrapper />);
88 expectWrapperTreeToEqual(null);
89
90 - // To test it, we tell the devtool to ignore next purge
90 + // To test it, we tell the hook to ignore next purge
91 // so the cleanup request by ReactDebugTool is ignored.
92 // This lets us make assertions on the actual tree.
93 ReactComponentTreeHook._preventPurging = true;
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
+2 -2
@@ -86,7 +86,7 @@ describe('ReactHostOperationHistoryHook', () => {
86 ReactHostOperationHistoryHook._preventClearing = true;
87 ReactDOM.render(<Foo />, node);
88
89 - // Empty DOM components should be invisible to devtools.
89 + // Empty DOM components should be invisible to hooks.
90 assertHistoryMatches([]);
91 });
92
@@ -106,7 +106,7 @@ describe('ReactHostOperationHistoryHook', () => {
106 ReactDOM.render(<Foo />, node);
107 var inst = ReactDOMComponentTree.getInstanceFromNode(node.firstChild);
108
109 - // Since empty components should be invisible to devtools,
109 + // Since empty components should be invisible to hooks,
110 // we record a "mount" event rather than a "replace with".
111 assertHistoryMatches([{
112 instanceID: inst._debugID,