Browse Source

FIX,REFA: handling parameter given as string or function

dev-feat-component_preview
chris 2 months ago
parent
commit
46f12f517d
  1. 14
      src/base/extStore.js

14
src/base/extStore.js

@ -68,14 +68,18 @@ function clearFunctionDeclarationText(func) {
* @returns {string} * @returns {string}
*/ */
function getScriptTagInjectionText(func, registrationName) { function getScriptTagInjectionText(func, registrationName) {
let funcHasName = func.name && func.name.trim() !== ''; let funcHasName;
if (func.startWith('function')) { if (typeof func === 'function') {
funcHasName = ((func.name) && func.name.trim() !== '');
}
if (func.startsWith('function')) {
let label = ` function ${registrationName}`; let label = ` function ${registrationName}`;
let isNameInFuncText = func.startWith(label); let isNameInFuncText = func.startsWith(label);
if (funcHasName && isNameInFuncText) { if (isNameInFuncText) {
return func; return func;
} else { } else {
return [label, '(', func.split('(', 1)[1]].join('') return [label, '(', func.split('(').slice(1).join('(')].join('')
} }
} else { } else {
return ` const ${registrationName} = ${func}; `; return ` const ${registrationName} = ${func}; `;

Loading…
Cancel
Save