convertPairToCSSText

说明

将给定的CSS样式键值对转化为cssText字符串

源码

https://github.com/ddzy/ts-utility-plugins/tree/master/src/ddzy/utility/dom/convertPairToCSSText

用法

convertPairToCSSText.test.ts
import { convertPairToCSSText } from "../../utility/dom/convertPairToCSSText";

describe('convertPairToCSSText', () => {
  test('convertPairToCSSText should extract CSS pair object into truthy cssText.', () => {
    const origin: Partial<CSSStyleDeclaration> = {
      border: '1px dotted red',
      backgroundColor: 'blue',
    };
    const expected = `border: 1px dotted red; background-color: blue; `;

    expect(convertPairToCSSText(origin)).toBe(expected);
  });
});

最后更新于