UNPKG

902 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7/**
8 * Easy to set element style, return previous style
9 * IE browser compatible(IE browser doesn't merge overflow style, need to set it separately)
10 * https://github.com/ant-design/ant-design/issues/19393
11 *
12 */
13function setStyle(style) {
14 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15 if (!style) {
16 return {};
17 }
18 var _options$element = options.element,
19 element = _options$element === void 0 ? document.body : _options$element;
20 var oldStyle = {};
21 var styleKeys = Object.keys(style);
22
23 // IE browser compatible
24 styleKeys.forEach(function (key) {
25 oldStyle[key] = element.style[key];
26 });
27 styleKeys.forEach(function (key) {
28 element.style[key] = style[key];
29 });
30 return oldStyle;
31}
32var _default = exports.default = setStyle;
\No newline at end of file