block-logical.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. var Declaration = require('../declaration');
  6. var BlockLogical = function (_Declaration) {
  7. _inherits(BlockLogical, _Declaration);
  8. function BlockLogical() {
  9. _classCallCheck(this, BlockLogical);
  10. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  11. }
  12. /**
  13. * Use old syntax for -moz- and -webkit-
  14. */
  15. BlockLogical.prototype.prefixed = function prefixed(prop, prefix) {
  16. return prefix + (prop.indexOf('-start') !== -1 ? prop.replace('-block-start', '-before') : prop.replace('-block-end', '-after'));
  17. };
  18. /**
  19. * Return property name by spec
  20. */
  21. BlockLogical.prototype.normalize = function normalize(prop) {
  22. if (prop.indexOf('-before') !== -1) {
  23. return prop.replace('-before', '-block-start');
  24. } else {
  25. return prop.replace('-after', '-block-end');
  26. }
  27. };
  28. return BlockLogical;
  29. }(Declaration);
  30. Object.defineProperty(BlockLogical, 'names', {
  31. enumerable: true,
  32. writable: true,
  33. value: ['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. });
  35. module.exports = BlockLogical;