pawajs 1.4.39 → 1.4.40
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.
- package/index.js +25 -15
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -324,26 +324,36 @@ export const createIntersectionObserver = (element, observeBy) => {
|
|
|
324
324
|
observer.observe(observeBy || element);
|
|
325
325
|
return observer;
|
|
326
326
|
}
|
|
327
|
-
RegisterComponent.lazy=
|
|
327
|
+
RegisterComponent.lazy=(...args)=>{
|
|
328
328
|
if (typeof args[0] === 'string') {
|
|
329
329
|
for (let i = 0; i < args.length; i += 2) {
|
|
330
330
|
const name = args[i];
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
if (typeof
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
331
|
+
const componentFunc = args[i + 1];
|
|
332
|
+
|
|
333
|
+
if (typeof componentFunc !== 'function') {
|
|
334
|
+
console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string|string[], function).');
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const processName =(compName) => {
|
|
339
|
+
if (components.has(compName.toUpperCase())) return;
|
|
340
|
+
if (typeof compName === 'string') {
|
|
341
|
+
if (isServer()) {
|
|
342
|
+
componentFunc();
|
|
343
|
+
}
|
|
344
|
+
lazyComponents.set(compName.toUpperCase(), { name: compName, component: componentFunc });
|
|
345
|
+
|
|
344
346
|
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
if (Array.isArray(name)) {
|
|
350
|
+
for (const compName of name) {
|
|
351
|
+
processName(compName);
|
|
352
|
+
}
|
|
353
|
+
} else if (typeof name === 'string') {
|
|
354
|
+
processName(name);
|
|
345
355
|
} else {
|
|
346
|
-
console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string, function).');
|
|
356
|
+
console.warn('Mismatched arguments for RegisterComponent. Expected pairs of (string|string[], function).');
|
|
347
357
|
break;
|
|
348
358
|
}
|
|
349
359
|
}
|