migrating.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _util = require('element-ui/lib/utils/util');
  4. /**
  5. * Show migrating guide in browser console.
  6. *
  7. * Usage:
  8. * import Migrating from 'element-ui/src/mixins/migrating';
  9. *
  10. * mixins: [Migrating]
  11. *
  12. * add getMigratingConfig method for your component.
  13. * getMigratingConfig() {
  14. * return {
  15. * props: {
  16. * 'allow-no-selection': 'allow-no-selection is removed.',
  17. * 'selection-mode': 'selection-mode is removed.'
  18. * },
  19. * events: {
  20. * selectionchange: 'selectionchange is renamed to selection-change.'
  21. * }
  22. * };
  23. * },
  24. */
  25. exports.default = {
  26. mounted: function mounted() {
  27. if (process.env.NODE_ENV === 'production') return;
  28. if (!this.$vnode) return;
  29. var _getMigratingConfig = this.getMigratingConfig(),
  30. _getMigratingConfig$p = _getMigratingConfig.props,
  31. props = _getMigratingConfig$p === undefined ? {} : _getMigratingConfig$p,
  32. _getMigratingConfig$e = _getMigratingConfig.events,
  33. events = _getMigratingConfig$e === undefined ? {} : _getMigratingConfig$e;
  34. var _$vnode = this.$vnode,
  35. data = _$vnode.data,
  36. componentOptions = _$vnode.componentOptions;
  37. var definedProps = data.attrs || {};
  38. var definedEvents = componentOptions.listeners || {};
  39. for (var propName in definedProps) {
  40. propName = (0, _util.kebabCase)(propName); // compatible with camel case
  41. if (props[propName]) {
  42. console.warn('[Element Migrating][' + this.$options.name + '][Attribute]: ' + props[propName]);
  43. }
  44. }
  45. for (var eventName in definedEvents) {
  46. eventName = (0, _util.kebabCase)(eventName); // compatible with camel case
  47. if (events[eventName]) {
  48. console.warn('[Element Migrating][' + this.$options.name + '][Event]: ' + events[eventName]);
  49. }
  50. }
  51. },
  52. methods: {
  53. getMigratingConfig: function getMigratingConfig() {
  54. return {
  55. props: {},
  56. events: {}
  57. };
  58. }
  59. }
  60. };