filter-value.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. (function() {
  2. var FilterValue, OldFilterValue, OldValue, Value, utils,
  3. __extends = 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(_super) {
  9. __extends(OldFilterValue, _super);
  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(_super) {
  30. __extends(FilterValue, _super);
  31. function FilterValue() {
  32. return FilterValue.__super__.constructor.apply(this, arguments);
  33. }
  34. FilterValue.names = ['filter'];
  35. FilterValue.prototype.replace = function(value, prefix) {
  36. if (prefix === '-webkit-') {
  37. if (value.indexOf('-webkit-filter') === -1) {
  38. return FilterValue.__super__.replace.apply(this, arguments) + ', ' + value;
  39. } else {
  40. return value;
  41. }
  42. } else {
  43. return FilterValue.__super__.replace.apply(this, arguments);
  44. }
  45. };
  46. FilterValue.prototype.old = function(prefix) {
  47. return new OldFilterValue(this.name, prefix + this.name);
  48. };
  49. return FilterValue;
  50. })(Value);
  51. module.exports = FilterValue;
  52. }).call(this);