Browse Source

Export correctly when option is used. Closes #2096

pull/2475/head
Artur Arseniev 6 years ago
parent
commit
da81f6beb7
  1. 6
      src/code_manager/model/HtmlGenerator.js
  2. 6
      src/dom_components/model/Component.js

6
src/code_manager/model/HtmlGenerator.js

@ -5,9 +5,9 @@ export default Backbone.Model.extend({
const models = model.get('components');
if (opts.exportWrapper) {
return opts.wrapperIsBody
? `<body>${this.buildModels(models)}</body>`
: model.toHTML();
return model.toHTML({
...(opts.wrapperIsBody && { tag: 'body' })
});
}
return this.buildModels(models);

6
src/dom_components/model/Component.js

@ -890,6 +890,7 @@ const Component = Backbone.Model.extend(Styleable).extend(
/**
* Return HTML string of the component
* @param {Object} [opts={}] Options
* @param {String} [opts.tag] Custom tagName
* @param {Object|Function} [opts.attributes=null] You can pass an object of custom attributes to replace
* with the current one or you can even pass a function to generate attributes dynamically
* @return {String} HTML string
@ -918,11 +919,12 @@ const Component = Backbone.Model.extend(Styleable).extend(
toHTML(opts = {}) {
const model = this;
const attrs = [];
const classes = [];
const tag = model.get('tagName');
const customTag = opts.tag;
const tag = customTag || model.get('tagName');
const sTag = model.get('void');
const customAttr = opts.attributes;
let attributes = this.getAttrToHTML();
delete opts.tag;
// Get custom attributes if requested
if (customAttr) {

Loading…
Cancel
Save