mirror of https://github.com/ElemeFE/element
Fix: migrating config not compatible with camel case props and events (#15260)
parent
5d58acac5c
commit
959b7b4698
|
@ -1,3 +1,4 @@
|
||||||
|
import { kebabCase } from 'element-ui/src/utils/util';
|
||||||
/**
|
/**
|
||||||
* Show migrating guide in browser console.
|
* Show migrating guide in browser console.
|
||||||
*
|
*
|
||||||
|
@ -29,13 +30,15 @@ export default {
|
||||||
const definedEvents = componentOptions.listeners || {};
|
const definedEvents = componentOptions.listeners || {};
|
||||||
|
|
||||||
for (let propName in definedProps) {
|
for (let propName in definedProps) {
|
||||||
if (definedProps.hasOwnProperty(propName) && props[propName]) {
|
propName = kebabCase(propName); // compatible with camel case
|
||||||
|
if (props[propName]) {
|
||||||
console.warn(`[Element Migrating][${this.$options.name}][Attribute]: ${props[propName]}`);
|
console.warn(`[Element Migrating][${this.$options.name}][Attribute]: ${props[propName]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let eventName in definedEvents) {
|
for (let eventName in definedEvents) {
|
||||||
if (definedEvents.hasOwnProperty(eventName) && events[eventName]) {
|
eventName = kebabCase(eventName); // compatible with camel case
|
||||||
|
if (events[eventName]) {
|
||||||
console.warn(`[Element Migrating][${this.$options.name}][Event]: ${events[eventName]}`);
|
console.warn(`[Element Migrating][${this.$options.name}][Event]: ${events[eventName]}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,3 +135,11 @@ export const autoprefixer = function(style) {
|
||||||
});
|
});
|
||||||
return style;
|
return style;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const kebabCase = function(str) {
|
||||||
|
const hyphenateRE = /([^-])([A-Z])/g;
|
||||||
|
return str
|
||||||
|
.replace(hyphenateRE, '$1-$2')
|
||||||
|
.replace(hyphenateRE, '$1-$2')
|
||||||
|
.toLowerCase();
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue