Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions packages/core/src/code_manager/model/HtmlGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ export default class HTMLGenerator extends Model {
})
.filter(Boolean);

if (!htmlOpts.attributes) {
htmlOpts.attributes = (mod, attrs) => {
const { id } = attrs;
if (
id &&
id[0] === 'i' && // all autogenerated IDs start with 'i'
!mod.get('script') && // if the component has script, we have to leave the ID
!mod.get('script-export') && // if the component has script, we have to leave the 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;
}
return attrs;
};
}
const attributes = htmlOpts.attributes;
htmlOpts.attributes = (mod, attrs) => {
attrs = typeof attributes === 'function' ? attributes(mod, attrs) : attrs;
const { id } = attrs;
if (
id &&
id[0] === 'i' && // all autogenerated IDs start with 'i'
!mod.get('script') && // if the component has script, we have to leave the ID
!mod.get('script-export') && // if the component has script, we have to leave the 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;
}
return attrs;
};
}

return model.toHTML(htmlOpts);
Expand Down