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