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.

60 lines
2.0 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 WritingMode =
  7. /*#__PURE__*/
  8. function (_Declaration) {
  9. _inheritsLoose(WritingMode, _Declaration);
  10. function WritingMode() {
  11. return _Declaration.apply(this, arguments) || this;
  12. }
  13. var _proto = WritingMode.prototype;
  14. _proto.insert = function insert(decl, prefix, prefixes) {
  15. if (prefix === '-ms-') {
  16. var cloned = this.set(this.clone(decl), prefix);
  17. if (this.needCascade(decl)) {
  18. cloned.raws.before = this.calcBefore(prefixes, decl, prefix);
  19. }
  20. var direction = 'ltr';
  21. decl.parent.nodes.forEach(function (i) {
  22. if (i.prop === 'direction') {
  23. if (i.value === 'rtl' || i.value === 'ltr') direction = i.value;
  24. }
  25. });
  26. cloned.value = WritingMode.msValues[direction][decl.value] || decl.value;
  27. return decl.parent.insertBefore(decl, cloned);
  28. }
  29. return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
  30. };
  31. return WritingMode;
  32. }(Declaration);
  33. _defineProperty(WritingMode, "names", ['writing-mode']);
  34. _defineProperty(WritingMode, "msValues", {
  35. ltr: {
  36. 'horizontal-tb': 'lr-tb',
  37. 'vertical-rl': 'tb-rl',
  38. 'vertical-lr': 'tb-lr'
  39. },
  40. rtl: {
  41. 'horizontal-tb': 'rl-tb',
  42. 'vertical-rl': 'bt-rl',
  43. 'vertical-lr': 'bt-lr'
  44. }
  45. });
  46. module.exports = WritingMode;