image-rendering.js 2.1 KB

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