border-radius.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 BorderRadius = function (_Declaration) {
  7. _inherits(BorderRadius, _Declaration);
  8. function BorderRadius() {
  9. _classCallCheck(this, BorderRadius);
  10. return _possibleConstructorReturn(this, _Declaration.apply(this, arguments));
  11. }
  12. /**
  13. * Change syntax, when add Mozilla prefix
  14. */
  15. BorderRadius.prototype.prefixed = function prefixed(prop, prefix) {
  16. if (prefix === '-moz-') {
  17. return prefix + (BorderRadius.toMozilla[prop] || prop);
  18. } else {
  19. return _Declaration.prototype.prefixed.call(this, prop, prefix);
  20. }
  21. };
  22. /**
  23. * Return unprefixed version of property
  24. */
  25. BorderRadius.prototype.normalize = function normalize(prop) {
  26. return BorderRadius.toNormal[prop] || prop;
  27. };
  28. return BorderRadius;
  29. }(Declaration);
  30. Object.defineProperty(BorderRadius, 'names', {
  31. enumerable: true,
  32. writable: true,
  33. value: ['border-radius']
  34. });
  35. Object.defineProperty(BorderRadius, 'toMozilla', {
  36. enumerable: true,
  37. writable: true,
  38. value: {}
  39. });
  40. Object.defineProperty(BorderRadius, 'toNormal', {
  41. enumerable: true,
  42. writable: true,
  43. value: {}
  44. });
  45. var _arr = ['top', 'bottom'];
  46. for (var _i = 0; _i < _arr.length; _i++) {
  47. var ver = _arr[_i];var _arr2 = ['left', 'right'];
  48. for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
  49. var hor = _arr2[_i2];
  50. var normal = 'border-' + ver + '-' + hor + '-radius';
  51. var mozilla = 'border-radius-' + ver + hor;
  52. BorderRadius.names.push(normal);
  53. BorderRadius.names.push(mozilla);
  54. BorderRadius.toMozilla[normal] = mozilla;
  55. BorderRadius.toNormal[mozilla] = normal;
  56. }
  57. }
  58. module.exports = BorderRadius;