block-logical.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 BlockLogical = /*#__PURE__*/function (_Declaration) {
  7. _inheritsLoose(BlockLogical, _Declaration);
  8. function BlockLogical() {
  9. return _Declaration.apply(this, arguments) || this;
  10. }
  11. var _proto = BlockLogical.prototype;
  12. /**
  13. * Use old syntax for -moz- and -webkit-
  14. */
  15. _proto.prefixed = function prefixed(prop, prefix) {
  16. if (prop.includes('-start')) {
  17. return prefix + prop.replace('-block-start', '-before');
  18. }
  19. return prefix + prop.replace('-block-end', '-after');
  20. }
  21. /**
  22. * Return property name by spec
  23. */
  24. ;
  25. _proto.normalize = function normalize(prop) {
  26. if (prop.includes('-before')) {
  27. return prop.replace('-before', '-block-start');
  28. }
  29. return prop.replace('-after', '-block-end');
  30. };
  31. return BlockLogical;
  32. }(Declaration);
  33. _defineProperty(BlockLogical, "names", ['border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', 'border-before', 'border-after', 'margin-before', 'margin-after', 'padding-before', 'padding-after']);
  34. module.exports = BlockLogical;