Skip to content

Commit 3c1dd1e

Browse files
fix setting File as value in store (T1327666)
1 parent 333e3e3 commit 3c1dd1e

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

packages/devextreme/js/__internal/core/utils/m_object.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const clone = (function () {
1010
};
1111
})();
1212

13+
const isBlobLike = function (value: unknown): boolean {
14+
return typeof Blob !== 'undefined' && value instanceof Blob;
15+
};
16+
1317
const orderEach = function (map, func) {
1418
const keys: string[] = [];
1519
let key;
@@ -93,6 +97,10 @@ const deepExtendArraySafe = function (target, changes, extendComplexObject?, ass
9397
let newValue;
9498
const assignFunc = useNewAssign ? newAssign : legacyAssign;
9599

100+
if (isBlobLike(changes)) {
101+
return changes;
102+
}
103+
96104
for (const name in changes) {
97105
prevValue = target[name];
98106
newValue = changes[name];

packages/devextreme/testing/tests/DevExpress.core/utils.object.tests.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,18 @@ QUnit.test('deepExtendArraySafe preserves custom object instances in arrays', fu
221221
assert.ok(result.items[0] instanceof CustomClass, 'First item preserves custom type');
222222
assert.ok(result.items[1] instanceof CustomClass, 'Second item preserves custom type');
223223
});
224+
225+
QUnit.test('deepExtendArraySafe assigns Blob/File by reference without throwing (nested newAssign)', function(assert) {
226+
const file = new File(['x'], 'test.txt', { type: 'text/plain' });
227+
const blob = new Blob(['y']);
228+
229+
const target = { id: 1, file: null, data: null };
230+
231+
objectUtils.deepExtendArraySafe(target, { file: file, data: blob }, true, false, true, objectUtils.newAssign);
232+
233+
assert.strictEqual(target.file, file);
234+
assert.strictEqual(target.data, blob);
235+
236+
const merged = objectUtils.deepExtendArraySafe({}, file, true, false, true, objectUtils.newAssign);
237+
assert.strictEqual(merged, file);
238+
});

0 commit comments

Comments
 (0)