Skip to content

Commit ab517bf

Browse files
committed
fix
1 parent f8b566d commit ab517bf

File tree

4 files changed

+49
-18
lines changed

4 files changed

+49
-18
lines changed

docs/en/blog/lynx-intro-to-web-platform.mdx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@ const __SetAttribute: SetAttributePAPI = (
9090
};
9191
```
9292
</div>
93+
<div>
94+
```cpp
95+
RENDERER_FUNCTION_CC(FiberSetAttribute) {
96+
CONVERT_ARG_AND_CHECK_FOR_ELEMENT_API(arg0, 0, RefCounted, FiberSetAttribute);
97+
auto element = fml::static_ref_ptr_cast<FiberElement>(arg0->RefCounted());
98+
CONVERT_ARG(arg1, 1);
99+
CONVERT_ARG(arg2, 2);
100+
auto string_type = arg1->StringView();
101+
CHECK_ILLEGAL_ATTRIBUTE_CONFIG(element, FiberSetAttribute);
102+
element->SetAttribute(arg1->String(), arg2->ToLepusValue());
103+
ON_NODE_MODIFIED(element);
104+
RETURN_UNDEFINED();
105+
}
106+
```
107+
</div>
108+
</div>
93109
94110
95111
This means that developers and Rspeedy (Rsbuild) plugin authors don't need extra work to support the web platform.
@@ -121,8 +137,6 @@ One of Lynx's core ideas is rendering based on native UI components, which means
121137
Just like Lynx's elements on iOS and Android, in browsers we provide a series of custom elements using [Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components).
122138
By using the lifecycles provided by web browsers, we don't depend on any JavaScript framework. This minimizes I/O overhead for applications built with Lynx.
123139
124-
![web-components](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/web-shadow-tree-web-c.jpeg)
125-
126140
## Faster, Easier, and a Rust-powered Future
127141
128142
### Boosted by Rust and WebAssembly
@@ -139,7 +153,7 @@ We know SSR is an important way to improve user experience. The web platform's S
139153
140154
## See our presentation on [React Universe Conf 2025](https://www.youtube.com/watch?v=-uUcYrl51JM)
141155
142-
[![React Universe Conf 2025](https://img.youtube.com/vi/Z4JHjv1gk0o/0.jpg)](https://www.youtube.com/watch?v=-uUcYrl51JM)
156+
[React Universe Conf 2025](https://www.youtube.com/watch?v=-uUcYrl51JM)
143157
144158
## Integrate with your web app now
145159

docs/en/guide/start/fragments/web/integrating-lynx-with-web.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Info } from '@lynx';
1313

1414
This assumes that you already have a Lynx project.
1515

16-
If you don't have a Lynx project yet please check this [Quick Start](guide/start/quick-start).
16+
If you don't have a Lynx project yet please check this [Quick Start](/guide/start/quick-start).
1717

1818
<Steps>
1919

docs/zh/blog/lynx-intro-to-web-platform.mdx

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,41 @@ Lynx Web 平台现已进入 Beta 阶段。下面是一些平台亮点。
6363

6464
![lynx-web-arch](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/arch-web-colorful-1.jpeg)
6565

66-
**__SetAttribute(Web 平台)**
67-
66+
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', columnGap: '20px' }}>
67+
<div style={{display: 'flex', justifyContent:'center'}}>**__SetAttribute on Web Platform**</div>
68+
<div style={{display: 'flex', justifyContent:'center',}}>**__SetAttribute on Lynx Engine**</div>
69+
<div>
6870
```js
6971
// lynx/runtime/papi.ts
7072
const __SetAttribute: SetAttributePAPI = (
71-
element,
72-
key,
73-
value,
73+
element,
74+
key,
75+
value,
7476
) => {
75-
if (value == null) {
76-
element.removeAttribute(key)
77-
} else {
78-
element.setAttribute(key, value + '')
79-
}
77+
if (value == null) {
78+
element.removeAttribute(key)
79+
} else {
80+
element.setAttribute(key, value + '')
81+
}
8082
};
8183
```
84+
</div>
85+
```cpp
86+
RENDERER_FUNCTION_CC(FiberSetAttribute) {
87+
CONVERT_ARG_AND_CHECK_FOR_ELEMENT_API(arg0, 0, RefCounted, FiberSetAttribute);
88+
auto element = fml::static_ref_ptr_cast<FiberElement>(arg0->RefCounted());
89+
CONVERT_ARG(arg1, 1);
90+
CONVERT_ARG(arg2, 2);
91+
auto string_type = arg1->StringView();
92+
CHECK_ILLEGAL_ATTRIBUTE_CONFIG(element, FiberSetAttribute);
93+
element->SetAttribute(arg1->String(), arg2->ToLepusValue());
94+
ON_NODE_MODIFIED(element);
95+
RETURN_UNDEFINED();
96+
}
97+
```
98+
<div>
99+
</div>
100+
</div>
82101
83102
这意味着开发者与 Rspeedy(Rsbuild)插件作者无需为 Web 平台做额外适配。
84103
你的代码无需针对不同平台维护多套变体。
@@ -109,8 +128,6 @@ Lynx 的一个核心理念是:基于原生 UI 组件进行渲染。这意味
109128
就像 iOS/Android 上的 Lynx 元素一样,在浏览器中我们提供了一系列基于 [Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) 的自定义元素。
110129
借助浏览器原生提供的生命周期,我们无需依赖任何 JavaScript 框架。这有助于将 I/O 开销降至最低。
111130
112-
![web-components](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/web-shadow-tree-web-c.jpeg)
113-
114131
## 更快,更易,用 Rust 驱动的未来
115132
116133
### 由 Rust 与 WebAssembly 驱动
@@ -128,7 +145,7 @@ Lynx 的一个核心理念是:基于原生 UI 组件进行渲染。这意味
128145
129146
## 观看我们在 [React Universe Conf 2025](https://www.youtube.com/watch?v=-uUcYrl51JM) 的演讲
130147
131-
[![React Universe Conf 2025](https://img.youtube.com/vi/Z4JHjv1gk0o/0.jpg)](https://www.youtube.com/watch?v=-uUcYrl51JM)
148+
[React Universe Conf 2025](https://www.youtube.com/watch?v=-uUcYrl51JM)
132149
133150
## 立即与你的 Web 应用集成
134151

docs/zh/guide/start/fragments/web/integrating-lynx-with-web.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Info } from '@lynx';
1111

1212
## 1. 构建 Lynx 产物
1313

14-
我们假设已经阅读并按照[快速开始](guide/start/quick-start)创建了一个 Lynx 项目。
14+
我们假设已经阅读并按照[快速开始](/guide/start/quick-start)创建了一个 Lynx 项目。
1515

1616
<Steps>
1717

0 commit comments

Comments
 (0)