项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

79 lines
2.9 KiB

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