You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.9 KiB

4 years ago
  1. "use strict";
  2. function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
  3. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
  4. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5. var Declaration = require('../declaration');
  6. var utils = require('./grid-utils');
  7. var GridRowColumn =
  8. /*#__PURE__*/
  9. function (_Declaration) {
  10. _inheritsLoose(GridRowColumn, _Declaration);
  11. function GridRowColumn() {
  12. return _Declaration.apply(this, arguments) || this;
  13. }
  14. var _proto = GridRowColumn.prototype;
  15. /**
  16. * Translate grid-row / grid-column to separate -ms- prefixed properties
  17. */
  18. _proto.insert = function insert(decl, prefix, prefixes) {
  19. if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
  20. var values = utils.parse(decl);
  21. var _utils$translate = utils.translate(values, 0, 1),
  22. start = _utils$translate[0],
  23. span = _utils$translate[1];
  24. var hasStartValueSpan = values[0] && values[0].includes('span');
  25. if (hasStartValueSpan) {
  26. span = values[0].join('').replace(/\D/g, '');
  27. }
  28. [[decl.prop, start], [decl.prop + "-span", span]].forEach(function (_ref) {
  29. var prop = _ref[0],
  30. value = _ref[1];
  31. utils.insertDecl(decl, prop, value);
  32. });
  33. return undefined;
  34. };
  35. return GridRowColumn;
  36. }(Declaration);
  37. _defineProperty(GridRowColumn, "names", ['grid-row', 'grid-column']);
  38. module.exports = GridRowColumn;