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.

63 lines
2.1 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 GridEnd =
  7. /*#__PURE__*/
  8. function (_Declaration) {
  9. _inheritsLoose(GridEnd, _Declaration);
  10. function GridEnd() {
  11. return _Declaration.apply(this, arguments) || this;
  12. }
  13. var _proto = GridEnd.prototype;
  14. /**
  15. * Change repeating syntax for IE
  16. */
  17. _proto.insert = function insert(decl, prefix, prefixes, result) {
  18. if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
  19. var clonedDecl = this.clone(decl);
  20. var startProp = decl.prop.replace(/end$/, 'start');
  21. var spanProp = prefix + decl.prop.replace(/end$/, 'span');
  22. if (decl.parent.some(function (i) {
  23. return i.prop === spanProp;
  24. })) {
  25. return undefined;
  26. }
  27. clonedDecl.prop = spanProp;
  28. if (decl.value.includes('span')) {
  29. clonedDecl.value = decl.value.replace(/span\s/i, '');
  30. } else {
  31. var startDecl;
  32. decl.parent.walkDecls(startProp, function (d) {
  33. startDecl = d;
  34. });
  35. if (startDecl) {
  36. var value = Number(decl.value) - Number(startDecl.value) + '';
  37. clonedDecl.value = value;
  38. } else {
  39. decl.warn(result, "Can not prefix " + decl.prop + " (" + startProp + " is not found)");
  40. }
  41. }
  42. decl.cloneBefore(clonedDecl);
  43. return undefined;
  44. };
  45. return GridEnd;
  46. }(Declaration);
  47. _defineProperty(GridEnd, "names", ['grid-row-end', 'grid-column-end']);
  48. module.exports = GridEnd;