Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions .changeset/light-facts-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@lynx-js/web-mainthread-apis": patch
"@lynx-js/web-webpack-plugin": patch
"@lynx-js/react-rsbuild-plugin": patch
---

fix(web): `:root` not work on web platform

Note: To solve this issue, you need to upgrade your `react-rsbuild-plugin`
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export class MainThreadRuntime {
const cssInJsInfo: CssInJsInfo = this.config.pageConfig.enableCSSSelector
? {}
: genCssInJsInfo(this.config.styleInfo);
this._rootDom = this.config.docu.createElement('div');
const cardStyleElement = this.config.docu.createElement('style');
cardStyleElement.innerHTML = genCssContent(
this.config.styleInfo,
Expand Down
6 changes: 6 additions & 0 deletions packages/web-platform/web-tests/tests/react.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ test.describe('reactlynx3 tests', () => {
await target.click();
await expect(target).toHaveCSS('background-color', 'rgb(0, 128, 0)'); // green
});
test('basic-style-root-selector', async ({ page }, { title }) => {
await goto(page, title);
await wait(100);
const target = page.locator('#target');
await expect(target).toHaveCSS('background-color', 'rgb(0, 128, 0)'); // green
});
test('basic-useeffect-hydrate', async ({ page }, { title }) => {
await goto(page, title);
await wait(100);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
// Copyright 2023 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
*/
:root {
background-color: green;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2023 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.
import { root, useCallback, useState } from '@lynx-js/react';
import './index.css';
function App() {
return (
<view
id='target'
class='basic'
style={{ height: '100px', width: '100px' }}
/>
);
}
root.render(
<page id='target'>
<App></App>
</page>,
);
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ export function genStyleInfo(
* [aa]:root {
* }
* ===>
* [aa][lynx-card-id] {
* [aa][lynx-tag="page"] {
* }
*/
plainSelectors.push('[lynx-card-id]');
plainSelectors.push('[lynx-tag="page"]');
} else if (selector.type === 'PseudoClassSelector') {
pseudoClassSelectors.push(CSS.csstree.generate(selector));
} else if (selector.type === 'PseudoElementSelector') {
Expand Down