waibu-mpa 2.6.3 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -190,8 +190,9 @@ class Wmpa {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
createComponentFromHtml = (html, wrapper) => {
|
|
193
|
+
createComponentFromHtml = (html, wrapper, returnText) => {
|
|
194
194
|
if (wrapper) html = '<' + wrapper + '>' + html + '</' + wrapper + '>'
|
|
195
|
+
if (returnText) return html
|
|
195
196
|
const tpl = document.createElement('template')
|
|
196
197
|
tpl.innerHTML = html
|
|
197
198
|
return tpl.content.firstElementChild
|
|
@@ -204,7 +205,7 @@ class Wmpa {
|
|
|
204
205
|
createComponent = async (body, wrapper, opts = {}) => {
|
|
205
206
|
if (_.isArray(body)) body = body.join('\n')
|
|
206
207
|
const html = await this.fetchRender(body, opts)
|
|
207
|
-
return this.createComponentFromHtml(html, wrapper)
|
|
208
|
+
return this.createComponentFromHtml(html, wrapper, opts.returnText)
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
replaceWithComponentHtml = (html, selector, wrapper) => {
|
|
@@ -241,9 +242,12 @@ class Wmpa {
|
|
|
241
242
|
else cmp = body
|
|
242
243
|
const el = this.getElement(selector)
|
|
243
244
|
if (!el) return
|
|
245
|
+
/*
|
|
244
246
|
if (checkChild) {
|
|
245
247
|
if (!el.hasChildNodes()) el.appendChild(cmp)
|
|
246
248
|
} else el.appendChild(cmp)
|
|
249
|
+
*/
|
|
250
|
+
el.appendChild(cmp)
|
|
247
251
|
return cmp.getAttribute('id')
|
|
248
252
|
}
|
|
249
253
|
|
package/package.json
CHANGED