migrating.js 1.8 KB

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