@esmx/router-vue 3.0.0-rc.79 → 3.0.0-rc.80
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/dist/util.mjs +3 -0
- package/dist/util.test.mjs +34 -0
- package/package.json +3 -3
- package/src/util.test.ts +41 -0
- package/src/util.ts +10 -0
package/dist/util.mjs
CHANGED
|
@@ -28,5 +28,8 @@ export function resolveComponent(component) {
|
|
|
28
28
|
if (isESModule(component)) {
|
|
29
29
|
return component.default || component;
|
|
30
30
|
}
|
|
31
|
+
if (component && typeof component === "object" && !Array.isArray(component) && "default" in component && Object.keys(component).length === 1) {
|
|
32
|
+
return component.default;
|
|
33
|
+
}
|
|
31
34
|
return component;
|
|
32
35
|
}
|
package/dist/util.test.mjs
CHANGED
|
@@ -267,6 +267,40 @@ describe("util.ts - Utility Functions", () => {
|
|
|
267
267
|
const classInstance = new ClassComponent();
|
|
268
268
|
expect(resolveComponent(classInstance)).toBe(classInstance);
|
|
269
269
|
});
|
|
270
|
+
it("should return default when object has only default key", () => {
|
|
271
|
+
const component = { default: "DefaultComponent" };
|
|
272
|
+
expect(resolveComponent(component)).toBe("DefaultComponent");
|
|
273
|
+
});
|
|
274
|
+
it("should return object when it has multiple keys including default", () => {
|
|
275
|
+
const component = {
|
|
276
|
+
default: "DefaultComponent",
|
|
277
|
+
other: "otherValue"
|
|
278
|
+
};
|
|
279
|
+
expect(resolveComponent(component)).toBe(component);
|
|
280
|
+
});
|
|
281
|
+
it("should return object when it has multiple keys without default", () => {
|
|
282
|
+
const component = {
|
|
283
|
+
prop1: "value1",
|
|
284
|
+
prop2: "value2"
|
|
285
|
+
};
|
|
286
|
+
expect(resolveComponent(component)).toBe(component);
|
|
287
|
+
});
|
|
288
|
+
it("should return object when it has single key that is not default", () => {
|
|
289
|
+
const component = { custom: "CustomComponent" };
|
|
290
|
+
expect(resolveComponent(component)).toBe(component);
|
|
291
|
+
});
|
|
292
|
+
it("should return array as is", () => {
|
|
293
|
+
const component = ["item1", "item2"];
|
|
294
|
+
expect(resolveComponent(component)).toBe(component);
|
|
295
|
+
});
|
|
296
|
+
it("should return object with single default key that is null", () => {
|
|
297
|
+
const component = { default: null };
|
|
298
|
+
expect(resolveComponent(component)).toBe(null);
|
|
299
|
+
});
|
|
300
|
+
it("should return object with single default key that is undefined", () => {
|
|
301
|
+
const component = { default: void 0 };
|
|
302
|
+
expect(resolveComponent(component)).toBe(void 0);
|
|
303
|
+
});
|
|
270
304
|
});
|
|
271
305
|
});
|
|
272
306
|
describe("createDependentProxy", () => {
|
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"vue": "^3.5.0 || ^2.7.0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@esmx/router": "3.0.0-rc.
|
|
53
|
+
"@esmx/router": "3.0.0-rc.80"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@biomejs/biome": "2.3.7",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vue": "3.5.23",
|
|
63
63
|
"vue2": "npm:vue@2.7.16"
|
|
64
64
|
},
|
|
65
|
-
"version": "3.0.0-rc.
|
|
65
|
+
"version": "3.0.0-rc.80",
|
|
66
66
|
"type": "module",
|
|
67
67
|
"private": false,
|
|
68
68
|
"exports": {
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"template",
|
|
82
82
|
"public"
|
|
83
83
|
],
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "3fca699d5b4daa50c2c53f4adea0e8a71e14765b"
|
|
85
85
|
}
|
package/src/util.test.ts
CHANGED
|
@@ -333,6 +333,47 @@ describe('util.ts - Utility Functions', () => {
|
|
|
333
333
|
const classInstance = new ClassComponent();
|
|
334
334
|
expect(resolveComponent(classInstance)).toBe(classInstance);
|
|
335
335
|
});
|
|
336
|
+
|
|
337
|
+
it('should return default when object has only default key', () => {
|
|
338
|
+
const component = { default: 'DefaultComponent' };
|
|
339
|
+
expect(resolveComponent(component)).toBe('DefaultComponent');
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('should return object when it has multiple keys including default', () => {
|
|
343
|
+
const component = {
|
|
344
|
+
default: 'DefaultComponent',
|
|
345
|
+
other: 'otherValue'
|
|
346
|
+
};
|
|
347
|
+
expect(resolveComponent(component)).toBe(component);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('should return object when it has multiple keys without default', () => {
|
|
351
|
+
const component = {
|
|
352
|
+
prop1: 'value1',
|
|
353
|
+
prop2: 'value2'
|
|
354
|
+
};
|
|
355
|
+
expect(resolveComponent(component)).toBe(component);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('should return object when it has single key that is not default', () => {
|
|
359
|
+
const component = { custom: 'CustomComponent' };
|
|
360
|
+
expect(resolveComponent(component)).toBe(component);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('should return array as is', () => {
|
|
364
|
+
const component = ['item1', 'item2'];
|
|
365
|
+
expect(resolveComponent(component)).toBe(component);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
it('should return object with single default key that is null', () => {
|
|
369
|
+
const component = { default: null };
|
|
370
|
+
expect(resolveComponent(component)).toBe(null);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('should return object with single default key that is undefined', () => {
|
|
374
|
+
const component = { default: undefined };
|
|
375
|
+
expect(resolveComponent(component)).toBe(undefined);
|
|
376
|
+
});
|
|
336
377
|
});
|
|
337
378
|
});
|
|
338
379
|
|
package/src/util.ts
CHANGED
|
@@ -41,5 +41,15 @@ export function resolveComponent(component: unknown): unknown {
|
|
|
41
41
|
return component.default || component;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
if (
|
|
45
|
+
component &&
|
|
46
|
+
typeof component === 'object' &&
|
|
47
|
+
!Array.isArray(component) &&
|
|
48
|
+
'default' in component &&
|
|
49
|
+
Object.keys(component).length === 1
|
|
50
|
+
) {
|
|
51
|
+
return component.default;
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
return component;
|
|
45
55
|
}
|