writing-mode.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 WritingMode = function (_Declaration) {
  7. _inherits(WritingMode, _Declaration);
  8. function WritingMode() {
  9. _classCallCheck(this, WritingMode);
  10. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  11. }
  12. WritingMode.prototype.set = function set(decl, prefix) {
  13. if (prefix === '-ms-') {
  14. decl.value = WritingMode.msValues[decl.value] || decl.value;
  15. return _Declaration.prototype.set.call(this, decl, prefix);
  16. } else {
  17. return _Declaration.prototype.set.call(this, decl, prefix);
  18. }
  19. };
  20. return WritingMode;
  21. }(Declaration);
  22. Object.defineProperty(WritingMode, 'names', {
  23. enumerable: true,
  24. writable: true,
  25. value: ['writing-mode']
  26. });
  27. Object.defineProperty(WritingMode, 'msValues', {
  28. enumerable: true,
  29. writable: true,
  30. value: {
  31. 'horizontal-tb': 'lr-tb',
  32. 'vertical-rl': 'tb-rl',
  33. 'vertical-lr': 'tb-lr'
  34. }
  35. });
  36. module.exports = WritingMode;