Browse Source

Honor the config.optsHtml option in HTMLGenerator

pull/4557/head
Artur Arseniev 4 years ago
parent
commit
e9c4bc9568
  1. 32
      src/code_manager/model/HtmlGenerator.js

32
src/code_manager/model/HtmlGenerator.js

@ -2,8 +2,8 @@ import { Model } from '../../common';
export default class HTMLGenerator extends Model { export default class HTMLGenerator extends Model {
build(model, opts = {}) { build(model, opts = {}) {
const htmlOpts = {}; const { em, ...restOpts } = opts;
const { em } = opts; const htmlOpts = restOpts;
// Remove unnecessary IDs // Remove unnecessary IDs
if (opts.cleanId && em) { if (opts.cleanId && em) {
@ -17,19 +17,21 @@ export default class HTMLGenerator extends Model {
}) })
.filter(i => i); .filter(i => i);
htmlOpts.attributes = (mod, attrs) => { if (!htmlOpts.attributes) {
const { id } = attrs; htmlOpts.attributes = (mod, attrs) => {
if ( const { id } = attrs;
id && if (
id[0] === 'i' && // all autogenerated IDs start with 'i' id &&
!mod.get('script') && // if the component has script, we have to leave the ID id[0] === 'i' && // all autogenerated IDs start with 'i'
!mod.get('attributes').id && // id is not intentionally in attributes !mod.get('script') && // if the component has script, we have to leave the ID
idRules.indexOf(id) < 0 // we shouldn't have any rule with this ID !mod.get('attributes').id && // id is not intentionally in attributes
) { idRules.indexOf(id) < 0 // we shouldn't have any rule with this ID
delete attrs.id; ) {
} delete attrs.id;
return attrs; }
}; return attrs;
};
}
} }
return model.toHTML(htmlOpts); return model.toHTML(htmlOpts);

Loading…
Cancel
Save