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.

75 lines
2.5 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 OldValue = require('../old-value');
  6. var Value = require('../value');
  7. function _regexp(name) {
  8. return new RegExp("(^|[\\s,(])(" + name + "($|[\\s),]))", 'gi');
  9. }
  10. var Intrinsic =
  11. /*#__PURE__*/
  12. function (_Value) {
  13. _inheritsLoose(Intrinsic, _Value);
  14. function Intrinsic() {
  15. return _Value.apply(this, arguments) || this;
  16. }
  17. var _proto = Intrinsic.prototype;
  18. _proto.regexp = function regexp() {
  19. if (!this.regexpCache) this.regexpCache = _regexp(this.name);
  20. return this.regexpCache;
  21. };
  22. _proto.isStretch = function isStretch() {
  23. return this.name === 'stretch' || this.name === 'fill' || this.name === 'fill-available';
  24. };
  25. _proto.replace = function replace(string, prefix) {
  26. if (prefix === '-moz-' && this.isStretch()) {
  27. return string.replace(this.regexp(), '$1-moz-available$3');
  28. }
  29. if (prefix === '-webkit-' && this.isStretch()) {
  30. return string.replace(this.regexp(), '$1-webkit-fill-available$3');
  31. }
  32. return _Value.prototype.replace.call(this, string, prefix);
  33. };
  34. _proto.old = function old(prefix) {
  35. var prefixed = prefix + this.name;
  36. if (this.isStretch()) {
  37. if (prefix === '-moz-') {
  38. prefixed = '-moz-available';
  39. } else if (prefix === '-webkit-') {
  40. prefixed = '-webkit-fill-available';
  41. }
  42. }
  43. return new OldValue(this.name, prefixed, prefixed, _regexp(prefixed));
  44. };
  45. _proto.add = function add(decl, prefix) {
  46. if (decl.prop.includes('grid') && prefix !== '-webkit-') {
  47. return undefined;
  48. }
  49. return _Value.prototype.add.call(this, decl, prefix);
  50. };
  51. return Intrinsic;
  52. }(Value);
  53. _defineProperty(Intrinsic, "names", ['max-content', 'min-content', 'fit-content', 'fill', 'fill-available', 'stretch']);
  54. module.exports = Intrinsic;