diff --git a/src/js/easymde.js b/src/js/easymde.js index f4a0c70..20a6c40 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -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'); }