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.

55 lines
1.8 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 list = require('postcss').list;
  6. var Value = require('../value');
  7. var CrossFade =
  8. /*#__PURE__*/
  9. function (_Value) {
  10. _inheritsLoose(CrossFade, _Value);
  11. function CrossFade() {
  12. return _Value.apply(this, arguments) || this;
  13. }
  14. var _proto = CrossFade.prototype;
  15. _proto.replace = function replace(string, prefix) {
  16. var _this = this;
  17. return list.space(string).map(function (value) {
  18. if (value.slice(0, +_this.name.length + 1) !== _this.name + '(') {
  19. return value;
  20. }
  21. var close = value.lastIndexOf(')');
  22. var after = value.slice(close + 1);
  23. var args = value.slice(_this.name.length + 1, close);
  24. if (prefix === '-webkit-') {
  25. var match = args.match(/\d*.?\d+%?/);
  26. if (match) {
  27. args = args.slice(match[0].length).trim();
  28. args += ", " + match[0];
  29. } else {
  30. args += ', 0.5';
  31. }
  32. }
  33. return prefix + _this.name + '(' + args + ')' + after;
  34. }).join(' ');
  35. };
  36. return CrossFade;
  37. }(Value);
  38. _defineProperty(CrossFade, "names", ['cross-fade']);
  39. module.exports = CrossFade;