image-rendering.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 ImageRendering = function (_Declaration) {
  7. _inherits(ImageRendering, _Declaration);
  8. function ImageRendering() {
  9. _classCallCheck(this, ImageRendering);
  10. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  11. }
  12. /**
  13. * Add hack only for crisp-edges
  14. */
  15. ImageRendering.prototype.check = function check(decl) {
  16. return decl.value === 'pixelated';
  17. };
  18. /**
  19. * Change property name for IE
  20. */
  21. ImageRendering.prototype.prefixed = function prefixed(prop, prefix) {
  22. if (prefix === '-ms-') {
  23. return '-ms-interpolation-mode';
  24. } else {
  25. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  26. }
  27. };
  28. /**
  29. * Change property and value for IE
  30. */
  31. ImageRendering.prototype.set = function set(decl, prefix) {
  32. if (prefix !== '-ms-') return _Declaration.prototype.set.call(this, decl, prefix);
  33. decl.prop = '-ms-interpolation-mode';
  34. decl.value = 'nearest-neighbor';
  35. return decl;
  36. };
  37. /**
  38. * Return property name by spec
  39. */
  40. ImageRendering.prototype.normalize = function normalize() {
  41. return 'image-rendering';
  42. };
  43. /**
  44. * Warn on old value
  45. */
  46. ImageRendering.prototype.process = function process(node, result) {
  47. return _Declaration.prototype.process.call(this, node, result);
  48. };
  49. return ImageRendering;
  50. }(Declaration);
  51. Object.defineProperty(ImageRendering, 'names', {
  52. enumerable: true,
  53. writable: true,
  54. value: ['image-rendering', 'interpolation-mode']
  55. });
  56. module.exports = ImageRendering;