mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] Locale: can not modify functional message (#3498)
This commit is contained in:
parent
1327ccb831
commit
639450709f
@ -11,7 +11,7 @@ function assignKey(to: ObjectIndex, from: ObjectIndex, key: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasOwnProperty.call(to, key) || !isObj(val)) {
|
||||
if (!hasOwnProperty.call(to, key) || !isObj(val) || typeof val === 'function') {
|
||||
to[key] = val;
|
||||
} else {
|
||||
to[key] = deepAssign(Object(to[key]), from[key]);
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { deepClone } from '../deep-clone';
|
||||
import { deepAssign } from '../deep-assign';
|
||||
import { isDef, get } from '..';
|
||||
import { raf, cancelRaf } from '../dom/raf';
|
||||
import { later } from '../../../test/utils';
|
||||
@ -11,7 +12,7 @@ import { camelize } from '../format/string';
|
||||
test('deepClone', () => {
|
||||
const a = { foo: 0 };
|
||||
const b = { foo: 0, bar: 1 };
|
||||
const fn = () => { };
|
||||
const fn = () => {};
|
||||
const arr = [a, b];
|
||||
expect(deepClone(a)).toEqual(a);
|
||||
expect(deepClone(b)).toEqual(b);
|
||||
@ -21,13 +22,30 @@ test('deepClone', () => {
|
||||
expect(deepClone(1)).toEqual(1);
|
||||
});
|
||||
|
||||
test('deepAssign', () => {
|
||||
const fn = () => {};
|
||||
|
||||
expect(deepAssign({}, { foo: null })).toEqual({});
|
||||
expect(deepAssign({}, { foo: undefined })).toEqual({});
|
||||
expect(deepAssign({ fn: null }, { fn })).toEqual({ fn });
|
||||
expect(deepAssign({ foo: 0 }, { bar: 1 })).toEqual({ foo: 0, bar: 1 });
|
||||
expect(deepAssign({ foo: { bar: false } }, { foo: { bar: true, foo: false } })).toEqual(
|
||||
{
|
||||
foo: {
|
||||
bar: true,
|
||||
foo: false
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('isDef', () => {
|
||||
expect(isDef(null)).toBeFalsy();
|
||||
expect(isDef(undefined)).toBeFalsy();
|
||||
expect(isDef(1)).toBeTruthy();
|
||||
expect(isDef('1')).toBeTruthy();
|
||||
expect(isDef({})).toBeTruthy();
|
||||
expect(isDef(() => { })).toBeTruthy();
|
||||
expect(isDef(() => {})).toBeTruthy();
|
||||
});
|
||||
|
||||
test('camelize', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user