source: imaps-frontend/node_modules/css-in-js-utils/es/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.5 KB
Line 
1function _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); }
2
3function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
5function _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."); }
6
7function _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); }
8
9function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
10
11function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
13function _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; }
14
15function filterUniqueArray(arr) {
16 return arr.filter(function (val, index) {
17 return arr.lastIndexOf(val) === index;
18 });
19}
20
21export default function assignStyle(base) {
22 for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; ++i) {
23 var style = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
24
25 for (var property in style) {
26 var value = style[property];
27 var baseValue = base[property];
28
29 if (baseValue && value) {
30 if (Array.isArray(baseValue)) {
31 base[property] = filterUniqueArray(baseValue.concat(value));
32 continue;
33 }
34
35 if (Array.isArray(value)) {
36 base[property] = filterUniqueArray([baseValue].concat(_toConsumableArray(value)));
37 continue;
38 }
39
40 if (_typeof(value) === 'object') {
41 base[property] = assignStyle({}, baseValue, value);
42 continue;
43 }
44 }
45
46 base[property] = value;
47 }
48 }
49
50 return base;
51}
Note: See TracBrowser for help on using the repository browser.