grid-rows-columns.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. var Declaration = require('../declaration');
  6. var shorthand = require('./grid-shorthand');
  7. var GridRowsColumns = function (_Declaration) {
  8. _inherits(GridRowsColumns, _Declaration);
  9. function GridRowsColumns() {
  10. _classCallCheck(this, GridRowsColumns);
  11. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  12. }
  13. /**
  14. * Change property name for IE
  15. */
  16. GridRowsColumns.prototype.prefixed = function prefixed(prop, prefix) {
  17. if (prefix === '-ms-') {
  18. return prefix + prop.replace('template-', '');
  19. } else {
  20. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  21. }
  22. };
  23. /**
  24. * Change IE property back
  25. */
  26. GridRowsColumns.prototype.normalize = function normalize(prop) {
  27. return prop.replace(/^grid-(rows|columns)/, 'grid-template-$1');
  28. };
  29. /**
  30. * Change repeating syntax for IE
  31. */
  32. GridRowsColumns.prototype.set = function set(decl, prefix) {
  33. if (prefix === '-ms-' && decl.value.indexOf('repeat(') !== -1) {
  34. decl.value = shorthand.changeRepeat(decl.value);
  35. }
  36. return _Declaration.prototype.set.call(this, decl, prefix);
  37. };
  38. return GridRowsColumns;
  39. }(Declaration);
  40. Object.defineProperty(GridRowsColumns, 'names', {
  41. enumerable: true,
  42. writable: true,
  43. value: ['grid-template-rows', 'grid-template-columns', 'grid-rows', 'grid-columns']
  44. });
  45. module.exports = GridRowsColumns;