2f0e36d58bfd9d8b390fee798ef0d6c84ae69d85ae4d39538212d1096555f0c4846dc0bbeee55eddab086340de18ce608547207d21bd6b184a233f4ecf0b71 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. (function() {
  2. var FilterValue, OldFilterValue, OldValue, Value, utils,
  3. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4. hasProp = {}.hasOwnProperty;
  5. OldValue = require('../old-value');
  6. Value = require('../value');
  7. utils = require('../utils');
  8. OldFilterValue = (function(superClass) {
  9. extend(OldFilterValue, superClass);
  10. function OldFilterValue() {
  11. return OldFilterValue.__super__.constructor.apply(this, arguments);
  12. }
  13. OldFilterValue.prototype.clean = function(decl) {
  14. return decl.value = utils.editList(decl.value, (function(_this) {
  15. return function(props) {
  16. if (props.every(function(i) {
  17. return i.indexOf(_this.unprefixed) !== 0;
  18. })) {
  19. return props;
  20. }
  21. return props.filter(function(i) {
  22. return i.indexOf(_this.prefixed) === -1;
  23. });
  24. };
  25. })(this));
  26. };
  27. return OldFilterValue;
  28. })(OldValue);
  29. FilterValue = (function(superClass) {
  30. extend(FilterValue, superClass);
  31. FilterValue.names = ['filter', 'filter-function'];
  32. function FilterValue(name, prefixes) {
  33. FilterValue.__super__.constructor.apply(this, arguments);
  34. if (name === 'filter-function') {
  35. this.name = 'filter';
  36. }
  37. }
  38. FilterValue.prototype.replace = function(value, prefix) {
  39. if (prefix === '-webkit-' && value.indexOf('filter(') === -1) {
  40. if (value.indexOf('-webkit-filter') === -1) {
  41. return FilterValue.__super__.replace.apply(this, arguments) + ', ' + value;
  42. } else {
  43. return value;
  44. }
  45. } else {
  46. return FilterValue.__super__.replace.apply(this, arguments);
  47. }
  48. };
  49. FilterValue.prototype.old = function(prefix) {
  50. return new OldFilterValue(this.name, prefix + this.name);
  51. };
  52. return FilterValue;
  53. })(Value);
  54. module.exports = FilterValue;
  55. }).call(this);