image-rendering.js 913 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. let Declaration = require('../declaration')
  2. class ImageRendering extends Declaration {
  3. /**
  4. * Add hack only for crisp-edges
  5. */
  6. check(decl) {
  7. return decl.value === 'pixelated'
  8. }
  9. /**
  10. * Change property name for IE
  11. */
  12. prefixed(prop, prefix) {
  13. if (prefix === '-ms-') {
  14. return '-ms-interpolation-mode'
  15. }
  16. return super.prefixed(prop, prefix)
  17. }
  18. /**
  19. * Change property and value for IE
  20. */
  21. set(decl, prefix) {
  22. if (prefix !== '-ms-') return super.set(decl, prefix)
  23. decl.prop = '-ms-interpolation-mode'
  24. decl.value = 'nearest-neighbor'
  25. return decl
  26. }
  27. /**
  28. * Return property name by spec
  29. */
  30. normalize() {
  31. return 'image-rendering'
  32. }
  33. /**
  34. * Warn on old value
  35. */
  36. process(node, result) {
  37. return super.process(node, result)
  38. }
  39. }
  40. ImageRendering.names = ['image-rendering', 'interpolation-mode']
  41. module.exports = ImageRendering