2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-07-21 08:54:28 -06:00

Move adding custom attributes above all others

This commit is contained in:
Jeroen Akkerman 2022-01-11 21:30:34 +01:00
parent 565c42e0ff
commit 98d9049728

View File

@ -219,6 +219,16 @@ function createToolbarDropdown(options, enableTooltips, shortcuts, parent) {
function createToolbarButton(options, enableActions, enableTooltips, shortcuts, markup, parent) {
options = options || {};
var el = document.createElement(markup);
// Add 'custom' attributes as early as possible, so that 'official' attributes will never be overwritten.
if (options.attributes) {
for (var attribute in options.attributes) {
if (Object.prototype.hasOwnProperty.call(options.attributes, attribute)) {
el.setAttribute(attribute, options.attributes[attribute]);
}
}
}
el.className = options.name;
el.setAttribute('type', markup);
enableTooltips = (enableTooltips == undefined) ? true : enableTooltips;
@ -237,14 +247,6 @@ function createToolbarButton(options, enableActions, enableTooltips, shortcuts,
}
}
if (options.attributes) {
for (var attribute in options.attributes) {
if (Object.prototype.hasOwnProperty.call(options.attributes, attribute)) {
el.setAttribute(attribute, options.attributes[attribute]);
}
}
}
if (options.noDisable) {
el.classList.add('no-disable');
}