Skip to content

Commit

Permalink
Core: Fix data and utils modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanblinov2k17 committed Oct 8, 2024
1 parent 1f03eb5 commit b7f0a10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions packages/devextreme/js/__internal/core/utils/m_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const { assign } = variableWrapper;

const bracketsToDots = function (expr) {
return expr
.replace(/\[/g, '@js/core/utils')
.replace(/\[/g, '.')
.replace(/\]/g, '');
};

export const getPathParts = function (name) {
return bracketsToDots(name).split('@js/core/utils');
return bracketsToDots(name).split('.');
};

const readPropValue = function (obj, propName, options) {
Expand Down Expand Up @@ -125,7 +125,7 @@ function combineGetters(getters) {
}

let current = result || (result = {});
const path = name.split('@js/core/utils');
const path = name.split('.');
const last = path.length - 1;

for (let i = 0; i < last; i++) {
Expand Down
24 changes: 13 additions & 11 deletions packages/devextreme/js/__internal/core/utils/m_extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@ import { isPlainObject } from '@js/core/utils/type';

export const extendFromObject = function (target, source, overrideExistingValues) {
target = target || {};
Object.keys(source).forEach((prop) => {
// eslint-disable-next-line no-restricted-syntax
for (const prop in source) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
const value = source[prop];
if (!(prop in target) || overrideExistingValues) {
target[prop] = value;
}
}
});
}
return target;
};

export const extend = function (target, ...args: any[]) {
target = target || {};
export const extend = function (...args) {
let target = args[0] || {};

let i = 0;
let i = 1;
let deep = false;

if (typeof target === 'boolean') {
deep = target;
target = args[0] || {};
target = args[1] || {};
i++;
}

Expand All @@ -31,19 +32,20 @@ export const extend = function (target, ...args: any[]) {
continue;
}

Object.keys(source).forEach((key) => {
// eslint-disable-next-line no-restricted-syntax, guard-for-in
for (const key in source) {
const targetValue = target[key];
const sourceValue = source[key];
let sourceValueIsArray = false;
let clone;

if (key === '__proto__' || key === 'constructor' || target === sourceValue) {
return;
continue;
}

if (deep && sourceValue && (isPlainObject(sourceValue)
// eslint-disable-next-line no-cond-assign
|| (sourceValueIsArray = Array.isArray(sourceValue)))) {
// eslint-disable-next-line no-cond-assign
|| (sourceValueIsArray = Array.isArray(sourceValue)))) {
if (sourceValueIsArray) {
clone = targetValue && Array.isArray(targetValue) ? targetValue : [];
} else {
Expand All @@ -54,7 +56,7 @@ export const extend = function (target, ...args: any[]) {
} else if (sourceValue !== undefined) {
target[key] = sourceValue;
}
});
}
}

return target;
Expand Down

0 comments on commit b7f0a10

Please sign in to comment.