FIX: allows to specify camelCased attributes in wrap component (#7919)
This commit is contained in:
parent
651a5b6e40
commit
67650328b4
|
@ -11,10 +11,16 @@ function parseAttributes(tagInfo) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function camelCaseToDash(str) {
|
||||||
|
return str.replace(/([a-zA-Z])(?=[A-Z])/g, "$1-").toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
function applyDataAttributes(token, state, attributes) {
|
function applyDataAttributes(token, state, attributes) {
|
||||||
Object.keys(attributes).forEach(tag => {
|
Object.keys(attributes).forEach(tag => {
|
||||||
const value = state.md.utils.escapeHtml(attributes[tag]);
|
const value = state.md.utils.escapeHtml(attributes[tag]);
|
||||||
tag = state.md.utils.escapeHtml(tag.replace(/[^a-z0-9\-]/g, ""));
|
tag = camelCaseToDash(
|
||||||
|
state.md.utils.escapeHtml(tag.replace(/[^A-Za-z\-0-9]/g, ""))
|
||||||
|
);
|
||||||
|
|
||||||
if (value && tag && tag.length > 1) {
|
if (value && tag && tag.length > 1) {
|
||||||
token.attrs.push([`data-${tag}`, value]);
|
token.attrs.push([`data-${tag}`, value]);
|
||||||
|
|
Loading…
Reference in New Issue