nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: DevExpress/devextreme-react
Pull request #326 (2019-03-21 07:13:07)

Fix empty dxForm item if it has multiple nested config-components


Patch:
diff --git a/src/core/options-manager.ts b/src/core/options-manager.ts
index 9302ea3..f7bf5d9 100644
--- a/src/core/options-manager.ts
+++ b/src/core/options-manager.ts
@@ -219,9 +219,13 @@ class OptionsManager {
             );
 
             const nestedObjects = this._getNestedOptionsObjects(e.children, templateRegistrationRequired);
+            const nestedObjectsCount =  Object.keys(nestedObjects).reduce((acc, item) => {
+                const obj = nestedObjects[item];
+                return acc + (Array.isArray(obj) ? obj.length : 1);
+            }, 0);
 
             const hasChildrenForTemplate =
-                ReactChildren.count(e.element.props.children) > Object.keys(nestedObjects).length;
+                ReactChildren.count(e.element.props.children) > nestedObjectsCount;
 
             if (templateRegistrationRequired) {
                 this._templateHost.add({


Test patch:
diff --git a/src/core/__tests__/template.test.tsx b/src/core/__tests__/template.test.tsx
index eb07d93..241bcaf 100644
--- a/src/core/__tests__/template.test.tsx
+++ b/src/core/__tests__/template.test.tsx
@@ -532,6 +532,10 @@ describe("component/render in nested options", () => {
 
                 <CollectionNestedComponent/>
 
+                <CollectionNestedComponent>
+                    <CollectionNestedComponent/>
+                    <CollectionNestedComponent/>
+                </CollectionNestedComponent>
             </TestComponent>
         );
 
@@ -543,6 +547,7 @@ describe("component/render in nested options", () => {
         expect(options["collection[3].template"]).toBe("collection[3].template");
         expect(options["collection[4].template"]).toBe(undefined);
         expect(options["collection[5].template"]).toBe(undefined);
+        expect(options["collection[6].template"]).toBe(undefined);
         expect(options["option.item"]).toBe(undefined);
         expect(options["option.template"]).toBe(undefined);
Repository: DevExpress/devextreme-react
Pull request #339 (2019-04-26 13:14:17)

Fix conditional nested components


Patch:
diff --git a/.vscode/settings.json b/.vscode/settings.json
index b3f05c3..4d3a689 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,4 +1,5 @@
 {
     "editor.tabSize": 4,
-    "editor.insertSpaces": true
+    "editor.insertSpaces": true,
+    "typescript.tsdk": "node_modules\\typescript\\lib"
 }
\ No newline at end of file
diff --git a/src/core/component-base.ts b/src/core/component-base.ts
index 9a6e62a..7199f9f 100644
--- a/src/core/component-base.ts
+++ b/src/core/component-base.ts
@@ -87,7 +87,9 @@ abstract class ComponentBase<P extends IHtmlOptions> extends React.PureComponent
     this._optionsManager.resetNestedElements();
 
     React.Children.forEach(this.props.children, (child: React.ReactElement<any>) => {
-      args.push(this._preprocessChild(child) || child);
+      if (child) {
+        args.push(this._preprocessChild(child) || child);
+      }
     });
 
     const templates = Object.getOwnPropertyNames(this.state.templates) || [];


Test patch:
diff --git a/src/core/__tests__/nested-option.test.tsx b/src/core/__tests__/nested-option.test.tsx
index 0db235c..a5c789c 100644
--- a/src/core/__tests__/nested-option.test.tsx
+++ b/src/core/__tests__/nested-option.test.tsx
@@ -1,6 +1,6 @@
 import { Component } from "../../core/component";
 import ConfigurationComponent from "../../core/nested-option";
-import { mount, React, shallow } from "./setup";
+import { mount, React } from "./setup";
 import { TestComponent, Widget, WidgetClass } from "./test-component";
 
 // tslint:disable:max-classes-per-file
@@ -70,6 +70,22 @@ describe("nested option", () => {
         });
     });
 
+    it("is not pulled during conditional rendering", () => {
+        mount(
+            <TestComponent>
+                <NestedComponent a={123} />
+                {false && <NestedComponent a={456} />}
+            </TestComponent>
+        );
+
+        expect(WidgetClass.mock.calls[0][1]).toEqual({
+            templatesRenderAsynchronously: true,
+            option: {
+                a: 123
+            }
+        });
+    });
+
     it("is pulled (several options)", () => {
         mount(
             <TestComponent>
Repository: DevExpress/devextreme-react
Pull request #501 (2021-02-11 17:15:41)

Add object check (T966657)


Patch:
diff --git a/package.json b/package.json
index 2be9f0c..3c6e406 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
     "css-loader": "^2.1.0",
     "del": "^3.0.0",
     "devextreme": "~20.2.4",
-    "devextreme-internal-tools": "stable",
+    "devextreme-internal-tools": "^3.3.0",
     "enzyme": "^3.7.0",
     "enzyme-adapter-react-16": "^1.6.0",
     "eslint": "^7.11.0",
diff --git a/src/core/configuration/tree.ts b/src/core/configuration/tree.ts
index 9f74b7c..3b40dea 100644
--- a/src/core/configuration/tree.ts
+++ b/src/core/configuration/tree.ts
@@ -81,7 +81,7 @@ enum ValueType {
   Array,
 }
 
-function findValueInObject(obj: any, path: string[]): undefined | IValueDescriptor {
+function findValueInObject(obj: unknown, path: string[]): undefined | IValueDescriptor {
   const key = path.shift();
   if (!key) {
     return {
@@ -90,7 +90,7 @@ function findValueInObject(obj: any, path: string[]): undefined | IValueDescript
     };
   }
 
-  if (Object.keys(obj).includes(key)) {
+  if (obj instanceof Object && Object.keys(obj).includes(key)) {
     return findValueInObject(obj[key], path);
   }
 
@@ -156,4 +156,5 @@ export {
   buildNode,
   buildTemplates,
   findValue,
+  findValueInObject
 };


Test patch:
diff --git a/src/core/configuration/__tests__/tree.test.ts b/src/core/configuration/__tests__/tree.test.ts
new file mode 100644
index 0000000..d7688bb
--- /dev/null
+++ b/src/core/configuration/__tests__/tree.test.ts
@@ -0,0 +1,31 @@
+/* eslint-disable max-classes-per-file */
+import { findValueInObject } from '../tree';
+
+describe('check findValueInObject', () => {
+
+    it("get underfined by string", () => {
+        const obj = "Extension";
+        const path = ["sortOrder"];
+        const valueInObject = findValueInObject(obj, path);
+        expect(() => findValueInObject(obj, path)).not.toThrow();
+        expect(valueInObject).toEqual(undefined);
+    });
+
+    it("get value by object", () => {
+        const obj = {
+            "sortOrder": "desc"
+        }
+        const path = ["sortOrder"];
+        const valueInObject = findValueInObject(obj, path);
+        expect(valueInObject).toEqual({ "type": 0, "value": "desc" });
+        expect(() => findValueInObject(obj, path)).not.toThrow();
+    })
+
+    it("get underfined by empty object",() =>{
+        const obj = {}
+        const path = ["sortOrder"];
+        const valueInObject = findValueInObject(obj, path);
+        expect(valueInObject).toEqual(undefined);
+        expect(() => findValueInObject(obj, path)).not.toThrow();
+    })
+})