source: imaps-frontend/node_modules/css-in-js-utils/lib/assignStyle.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.6 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports["default"] = assignStyle;
7
8function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9
10function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
12function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
14function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
16function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
17
18function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
19
20function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
21
22function filterUniqueArray(arr) {
23 return arr.filter(function (val, index) {
24 return arr.lastIndexOf(val) === index;
25 });
26}
27
28function assignStyle(base) {
29 for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; ++i) {
30 var style = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
31
32 for (var property in style) {
33 var value = style[property];
34 var baseValue = base[property];
35
36 if (baseValue && value) {
37 if (Array.isArray(baseValue)) {
38 base[property] = filterUniqueArray(baseValue.concat(value));
39 continue;
40 }
41
42 if (Array.isArray(value)) {
43 base[property] = filterUniqueArray([baseValue].concat(_toConsumableArray(value)));
44 continue;
45 }
46
47 if (_typeof(value) === 'object') {
48 base[property] = assignStyle({}, baseValue, value);
49 continue;
50 }
51 }
52
53 base[property] = value;
54 }
55 }
56
57 return base;
58}
Note: See TracBrowser for help on using the repository browser.