diff --git a/node_modules/htmltojsx/src/htmltojsx.js b/node_modules/htmltojsx/src/htmltojsx.js index afe4c85..960e450 100644 --- a/node_modules/htmltojsx/src/htmltojsx.js +++ b/node_modules/htmltojsx/src/htmltojsx.js @@ -326,19 +326,9 @@ HTMLtoJSX.prototype = { convert: function(html) { this.reset(); - var containerEl = createElement('div'); + var containerEl = createElement('null'); containerEl.innerHTML = '\n' + this._cleanInput(html) + '\n'; - if (this.config.createClass) { - if (this.config.outputClassName) { - this.output = 'var ' + this.config.outputClassName + ' = React.createClass({\n'; - } else { - this.output = 'React.createClass({\n'; - } - this.output += this.config.indent + 'render: function() {' + "\n"; - this.output += this.config.indent + this.config.indent + 'return (\n'; - } - if (this._onlyOneTopLevel(containerEl)) { // Only one top-level element, the component can return it directly // No need to actually visit the container element @@ -351,13 +341,14 @@ HTMLtoJSX.prototype = { this._visit(containerEl); } this.output = this.output.trim() + '\n'; - if (this.config.createClass) { - this.output += this.config.indent + this.config.indent + ');\n'; - this.output += this.config.indent + '}\n'; - this.output += '});'; - } else { - this.output = this._removeJSXClassIndention(this.output, this.config.indent); + this.output = this._removeJSXClassIndention(this.output, this.config.indent); + + if (this.output.trim().startsWith("{") || this.output.trim().endsWith("}")) { + this.output = `<>\n${this.output}` + } else if (this.output.trim().startsWith("") && this.output.trim().endsWith("")) { + this.output = this.output.replace("", "<>").replace("", "") } + return this.output; }, @@ -627,6 +618,8 @@ HTMLtoJSX.prototype = { result += '={' + attribute.value + '}'; } else if (attribute.value.length > 0) { result += '="' + attribute.value.replace(/"/gm, '"') + '"'; + } else { + result += '=""'; } return result; }