place-self.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 PlaceSelf = /*#__PURE__*/function (_Declaration) {
  8. _inheritsLoose(PlaceSelf, _Declaration);
  9. function PlaceSelf() {
  10. return _Declaration.apply(this, arguments) || this;
  11. }
  12. var _proto = PlaceSelf.prototype;
  13. /**
  14. * Translate place-self to separate -ms- prefixed properties
  15. */
  16. _proto.insert = function insert(decl, prefix, prefixes) {
  17. if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes); // prevent doubling of prefixes
  18. if (decl.parent.some(function (i) {
  19. return i.prop === '-ms-grid-row-align';
  20. })) {
  21. return undefined;
  22. }
  23. var _utils$parse = utils.parse(decl),
  24. _utils$parse$ = _utils$parse[0],
  25. first = _utils$parse$[0],
  26. second = _utils$parse$[1];
  27. if (second) {
  28. utils.insertDecl(decl, 'grid-row-align', first);
  29. utils.insertDecl(decl, 'grid-column-align', second);
  30. } else {
  31. utils.insertDecl(decl, 'grid-row-align', first);
  32. utils.insertDecl(decl, 'grid-column-align', first);
  33. }
  34. return undefined;
  35. };
  36. return PlaceSelf;
  37. }(Declaration);
  38. _defineProperty(PlaceSelf, "names", ['place-self']);
  39. module.exports = PlaceSelf;