grid-end.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 GridEnd = function (_Declaration) {
  7. _inherits(GridEnd, _Declaration);
  8. function GridEnd() {
  9. _classCallCheck(this, GridEnd);
  10. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  11. }
  12. /**
  13. * Do not add prefix for unsupported value in IE
  14. */
  15. GridEnd.prototype.check = function check(decl) {
  16. return decl.value.indexOf('span') !== -1;
  17. };
  18. /**
  19. * Return a final spec property
  20. */
  21. GridEnd.prototype.normalize = function normalize(prop) {
  22. return prop.replace(/(-span|-end)/, '');
  23. };
  24. /**
  25. * Change property name for IE
  26. */
  27. GridEnd.prototype.prefixed = function prefixed(prop, prefix) {
  28. var result = _Declaration.prototype.prefixed.call(this, prop, prefix);
  29. if (prefix === '-ms-') {
  30. result = result.replace('-end', '-span');
  31. }
  32. return result;
  33. };
  34. /**
  35. * Change repeating syntax for IE
  36. */
  37. GridEnd.prototype.set = function set(decl, prefix) {
  38. if (prefix === '-ms-') {
  39. decl.value = decl.value.replace(/span\s/i, '');
  40. }
  41. return _Declaration.prototype.set.call(this, decl, prefix);
  42. };
  43. return GridEnd;
  44. }(Declaration);
  45. Object.defineProperty(GridEnd, 'names', {
  46. enumerable: true,
  47. writable: true,
  48. value: ['grid-row-end', 'grid-column-end', 'grid-row-span', 'grid-column-span']
  49. });
  50. module.exports = GridEnd;