mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-13 11:34:02 +08:00
Fix: migrating config not compatible with camel case props and events (#15260)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { kebabCase } from 'element-ui/src/utils/util';
|
||||
/**
|
||||
* Show migrating guide in browser console.
|
||||
*
|
||||
@@ -29,13 +30,15 @@ export default {
|
||||
const definedEvents = componentOptions.listeners || {};
|
||||
|
||||
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]}`);
|
||||
}
|
||||
}
|
||||
|
||||
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]}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,3 +135,11 @@ export const autoprefixer = function(style) {
|
||||
});
|
||||
return style;
|
||||
};
|
||||
|
||||
export const kebabCase = function(str) {
|
||||
const hyphenateRE = /([^-])([A-Z])/g;
|
||||
return str
|
||||
.replace(hyphenateRE, '$1-$2')
|
||||
.replace(hyphenateRE, '$1-$2')
|
||||
.toLowerCase();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user