Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-card-entry-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/web-core": patch
---

fix(web-core): skip setting lynxEntryNameAttribute for **Card** and use constants for server element APIs
Comment thread
PupilTong marked this conversation as resolved.
5 changes: 5 additions & 0 deletions .changeset/solid-boats-lead.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@lynx-js/web-core": patch
---

fix: add cardType resolution for legacy json lynx bundle
17 changes: 16 additions & 1 deletion packages/web-platform/web-core/tests/element-apis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, test, expect, beforeEach, beforeAll } from 'vitest';
import { createElementAPI } from '../ts/client/mainthread/elementAPIs/createElementAPI.js';
import { WASMJSBinding } from '../ts/client/mainthread/elementAPIs/WASMJSBinding.js';
import { vi } from 'vitest';
import { cssIdAttribute } from '../ts/constants.js';
import { cssIdAttribute, lynxEntryNameAttribute } from '../ts/constants.js';
import {
createElementAPI as createServerElementAPI,
SSRBinding,
Expand Down Expand Up @@ -128,6 +128,21 @@ describe('Element APIs', () => {
expect(mtsGlobalThis.__GetAttributeByName(ret, 'name')).toBe('name');
});

test('__CreateComponent drops __Card__ entryName', () => {
const ret = mtsGlobalThis.__CreateComponent(
0,
'id',
0,
'__Card__',
'name',
'path',
{},
{},
);
expect(mtsGlobalThis.__GetAttributeByName(ret, lynxEntryNameAttribute))
.toBe(null);
});

test('client component_css_id properly cascades to child element', () => {
const root = mtsGlobalThis.__CreatePage('page', 0);
const comp = mtsGlobalThis.__CreateComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ async function handleJSON(
?? (json.lepusCode.root.startsWith('(function (globDynamicComponentEntry')
? 'lazy'
: 'card');
config.cardType = json.cardType ?? json.pageConfig?.cardType ?? 'react';
config.appType = config.appType ?? appType;
config.isLazy = (appType === 'card') ? 'false' : 'true';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export function createElementAPI(
componentCSSID,
componentID,
);
if (entryName) {
if (entryName && entryName !== '__Card__') {
dom.setAttribute(lynxEntryNameAttribute, entryName);
}
if (name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
LYNX_TAG_TO_HTML_TAG_MAP,
uniqueIdSymbol,
lynxDefaultDisplayLinearAttribute,
lynxDefaultOverflowVisibleAttribute,
lynxEntryNameAttribute,
lynxUniqueIdAttribute,
} from '../../constants.js';
import type {
AddClassPAPI,
Expand Down Expand Up @@ -309,7 +311,7 @@ export function createElementAPI(
const id = wasmContext.create_element(htmlTag, parentComponentUniqueId);
const el = { [uniqueIdSymbol]: id };
if (!config.enableCSSSelector) {
wasmContext.set_attribute(id, 'l-uid', id.toString());
wasmContext.set_attribute(id, lynxUniqueIdAttribute, id.toString());
}
return el as unknown as DecoratedHTMLElement;
}) as CreateElementPAPI,
Expand All @@ -328,10 +330,10 @@ export function createElementAPI(
); // Component host
const el = { [uniqueIdSymbol]: id } as ServerElement;
if (!config.enableCSSSelector) {
wasmContext.set_attribute(id, 'l-uid', id.toString());
wasmContext.set_attribute(id, lynxUniqueIdAttribute, id.toString());
}
if (entryName) {
wasmContext.set_attribute(id, 'lynx-entry-name', entryName);
if (entryName && entryName !== '__Card__') {
wasmContext.set_attribute(id, lynxEntryNameAttribute, entryName);
}
if (name) {
wasmContext.set_attribute(id, 'name', name);
Expand Down Expand Up @@ -362,7 +364,7 @@ export function createElementAPI(
pageElementId = id;
const el = { [uniqueIdSymbol]: id } as ServerElement;
if (!config.enableCSSSelector) {
wasmContext.set_attribute(id, 'l-uid', id.toString());
wasmContext.set_attribute(id, lynxUniqueIdAttribute, id.toString());
}
wasmContext.set_attribute(id, 'part', 'page');

Expand All @@ -376,7 +378,7 @@ export function createElementAPI(
if (config.defaultOverflowVisible === true) {
wasmContext.set_attribute(
id,
'lynx-default-overflow-visible',
lynxDefaultOverflowVisibleAttribute,
'true',
);
}
Expand Down
Loading