background-size.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 BackgroundSize = function (_Declaration) {
  7. _inherits(BackgroundSize, _Declaration);
  8. function BackgroundSize() {
  9. _classCallCheck(this, BackgroundSize);
  10. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  11. }
  12. /**
  13. * Duplication parameter for -webkit- browsers
  14. */
  15. BackgroundSize.prototype.set = function set(decl, prefix) {
  16. var value = decl.value.toLowerCase();
  17. if (prefix === '-webkit-' && value.indexOf(' ') === -1 && value !== 'contain' && value !== 'cover') {
  18. decl.value = decl.value + ' ' + decl.value;
  19. }
  20. return _Declaration.prototype.set.call(this, decl, prefix);
  21. };
  22. return BackgroundSize;
  23. }(Declaration);
  24. Object.defineProperty(BackgroundSize, 'names', {
  25. enumerable: true,
  26. writable: true,
  27. value: ['background-size']
  28. });
  29. module.exports = BackgroundSize;