image-rendering.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. "use strict";
  2. function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
  3. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
  4. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  5. var Declaration = require('../declaration');
  6. var ImageRendering = /*#__PURE__*/function (_Declaration) {
  7. _inheritsLoose(ImageRendering, _Declaration);
  8. function ImageRendering() {
  9. return _Declaration.apply(this, arguments) || this;
  10. }
  11. var _proto = ImageRendering.prototype;
  12. /**
  13. * Add hack only for crisp-edges
  14. */
  15. _proto.check = function check(decl) {
  16. return decl.value === 'pixelated';
  17. }
  18. /**
  19. * Change property name for IE
  20. */
  21. ;
  22. _proto.prefixed = function prefixed(prop, prefix) {
  23. if (prefix === '-ms-') {
  24. return '-ms-interpolation-mode';
  25. }
  26. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  27. }
  28. /**
  29. * Change property and value for IE
  30. */
  31. ;
  32. _proto.set = function set(decl, prefix) {
  33. if (prefix !== '-ms-') return _Declaration.prototype.set.call(this, decl, prefix);
  34. decl.prop = '-ms-interpolation-mode';
  35. decl.value = 'nearest-neighbor';
  36. return decl;
  37. }
  38. /**
  39. * Return property name by spec
  40. */
  41. ;
  42. _proto.normalize = function normalize() {
  43. return 'image-rendering';
  44. }
  45. /**
  46. * Warn on old value
  47. */
  48. ;
  49. _proto.process = function process(node, result) {
  50. return _Declaration.prototype.process.call(this, node, result);
  51. };
  52. return ImageRendering;
  53. }(Declaration);
  54. _defineProperty(ImageRendering, "names", ['image-rendering', 'interpolation-mode']);
  55. module.exports = ImageRendering;