@samitouri / QOS-React-2 / commits / ef67406272

Add simple React.createDescriptor hook

This is the minimal runtime change we need to switch the JSX syntax to resolve to React.createDescriptor(...)

Sebastian Markbage committed Jun 26, 2014 at 15:37 UTC ef6740627292136973a6b8053cc98dba98ebd18f
2 files changed +17
src/browser/ui/React.js
+4
@@ -53,6 +53,10 @@ var React = {
53 EventPluginUtils.useTouchEvents = shouldUseTouch;
54 },
55 createClass: ReactCompositeComponent.createClass,
56 + createDescriptor: function(type, props, children) {
57 + var args = Array.prototype.slice.call(arguments, 1);
58 + return type.apply(null, args);
59 + },
60 constructAndRenderComponent: ReactMount.constructAndRenderComponent,
61 constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
62 renderComponent: ReactPerf.measure(
src/core/__tests__/ReactDescriptor-test.js
+13
@@ -45,4 +45,17 @@ describe('ReactDescriptor', function() {
45 expect(ReactDescriptor.isValidDescriptor(React.DOM.div)).toEqual(false);
46 expect(ReactDescriptor.isValidDescriptor(Component)).toEqual(false);
47 });
48 +
49 + it('immediately calls the type passed to createDescriptor', function() {
50 + var a = 1, b = 2, c = 3, d = 4;
51 +
52 + var foo = jest.genMockFunction();
53 + foo.mockReturnValue(d);
54 +
55 + var result = React.createDescriptor(foo, a, b, c);
56 +
57 + expect(result).toBe(d);
58 + expect(foo).toBeCalledWith(a, b, c);
59 + });
60 +
61 });