mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-09-08 21:19:30 +00:00
fix(core): 为背景图片 URL 添加引号
This commit is contained in:
parent
cde0805292
commit
97e0cac44a
@ -51,7 +51,7 @@ export const style2Obj = (style: string) => {
|
|||||||
|
|
||||||
export const fillBackgroundImage = (value: string) => {
|
export const fillBackgroundImage = (value: string) => {
|
||||||
if (value && !/^url/.test(value) && !/^linear-gradient/.test(value)) {
|
if (value && !/^url/.test(value) && !/^linear-gradient/.test(value)) {
|
||||||
return `url(${value})`;
|
return `url("${value}")`;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -50,7 +50,7 @@ describe('style2Obj', () => {
|
|||||||
|
|
||||||
describe('fillBackgroundImage', () => {
|
describe('fillBackgroundImage', () => {
|
||||||
test('裸路径会包裹 url()', () => {
|
test('裸路径会包裹 url()', () => {
|
||||||
expect(fillBackgroundImage('a.png')).toBe('url(a.png)');
|
expect(fillBackgroundImage('a.png')).toBe('url("a.png")');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('已经是 url() 不重复包裹', () => {
|
test('已经是 url() 不重复包裹', () => {
|
||||||
@ -127,7 +127,7 @@ describe('transformStyle', () => {
|
|||||||
|
|
||||||
test('backgroundImage: browser 下补全 url()', () => {
|
test('backgroundImage: browser 下补全 url()', () => {
|
||||||
expect(transformStyle({ backgroundImage: 'a.png' }, 'browser')).toEqual({
|
expect(transformStyle({ backgroundImage: 'a.png' }, 'browser')).toEqual({
|
||||||
backgroundImage: 'url(a.png)',
|
backgroundImage: 'url("a.png")',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user