display-flex.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. (function() {
  2. var DisplayFlex, OldValue, Value, flexSpec,
  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. flexSpec = require('./flex-spec');
  6. OldValue = require('../old-value');
  7. Value = require('../value');
  8. DisplayFlex = (function(superClass) {
  9. extend(DisplayFlex, superClass);
  10. DisplayFlex.names = ['display-flex', 'inline-flex'];
  11. function DisplayFlex(name, prefixes) {
  12. DisplayFlex.__super__.constructor.apply(this, arguments);
  13. if (name === 'display-flex') {
  14. this.name = 'flex';
  15. }
  16. }
  17. DisplayFlex.prototype.check = function(decl) {
  18. return decl.prop === 'display' && decl.value === this.name;
  19. };
  20. DisplayFlex.prototype.prefixed = function(prefix) {
  21. var ref, spec;
  22. ref = flexSpec(prefix), spec = ref[0], prefix = ref[1];
  23. return prefix + (spec === 2009 ? this.name === 'flex' ? 'box' : 'inline-box' : spec === 2012 ? this.name === 'flex' ? 'flexbox' : 'inline-flexbox' : spec === 'final' ? this.name : void 0);
  24. };
  25. DisplayFlex.prototype.replace = function(string, prefix) {
  26. return this.prefixed(prefix);
  27. };
  28. DisplayFlex.prototype.old = function(prefix) {
  29. var prefixed;
  30. prefixed = this.prefixed(prefix);
  31. if (prefixed) {
  32. return new OldValue(this.name, prefixed);
  33. }
  34. };
  35. return DisplayFlex;
  36. })(Value);
  37. module.exports = DisplayFlex;
  38. }).call(this);