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.

77 lines
2.4 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 BreakProps =
  7. /*#__PURE__*/
  8. function (_Declaration) {
  9. _inheritsLoose(BreakProps, _Declaration);
  10. function BreakProps() {
  11. return _Declaration.apply(this, arguments) || this;
  12. }
  13. var _proto = BreakProps.prototype;
  14. /**
  15. * Change name for -webkit- and -moz- prefix
  16. */
  17. _proto.prefixed = function prefixed(prop, prefix) {
  18. return prefix + "column-" + prop;
  19. }
  20. /**
  21. * Return property name by final spec
  22. */
  23. ;
  24. _proto.normalize = function normalize(prop) {
  25. if (prop.includes('inside')) {
  26. return 'break-inside';
  27. }
  28. if (prop.includes('before')) {
  29. return 'break-before';
  30. }
  31. return 'break-after';
  32. }
  33. /**
  34. * Change prefixed value for avoid-column and avoid-page
  35. */
  36. ;
  37. _proto.set = function set(decl, prefix) {
  38. if (decl.prop === 'break-inside' && decl.value === 'avoid-column' || decl.value === 'avoid-page') {
  39. decl.value = 'avoid';
  40. }
  41. return _Declaration.prototype.set.call(this, decl, prefix);
  42. }
  43. /**
  44. * Dont prefix some values
  45. */
  46. ;
  47. _proto.insert = function insert(decl, prefix, prefixes) {
  48. if (decl.prop !== 'break-inside') {
  49. return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
  50. }
  51. if (/region/i.test(decl.value) || /page/i.test(decl.value)) {
  52. return undefined;
  53. }
  54. return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
  55. };
  56. return BreakProps;
  57. }(Declaration);
  58. _defineProperty(BreakProps, "names", ['break-inside', 'page-break-inside', 'column-break-inside', 'break-before', 'page-break-before', 'column-break-before', 'break-after', 'page-break-after', 'column-break-after']);
  59. module.exports = BreakProps;