File tree Expand file tree Collapse file tree 5 files changed +34
-45
lines changed
src/js/packages/@reactpy/client/src Expand file tree Collapse file tree 5 files changed +34
-45
lines changed Original file line number Diff line number Diff line change 11import eventToObject from "event-to-object" ;
2+ import { Fragment } from "preact" ;
23import type {
34 ReactPyVdom ,
45 ReactPyVdomImportSource ,
Original file line number Diff line number Diff line change 1+ from pathlib import Path
2+
13import pytest
24
35import reactpy
46from reactpy import html
57from reactpy .reactjs import component_from_string , import_reactjs
68from reactpy .testing import BackendFixture , DisplayFixture
79
10+ JS_FIXTURES_DIR = Path (__file__ ).parent / "js_fixtures"
11+
812
913@pytest .fixture (scope = "module" )
1014async def display (browser ):
@@ -89,3 +93,24 @@ def App():
8993 elements = await display .page .query_selector_all (".component-c" )
9094 assert len (elements ) == 2
9195 await display .page .wait_for_selector ("#deep-server" )
96+
97+
98+ async def test_nest_custom_component_under_web_component (display : DisplayFixture ):
99+ """
100+ Fix https://github.com/reactive-python/reactpy/discussions/1323
101+
102+ Custom components (i.e those wrapped in the component decorator) were not able to
103+ be nested under web components.
104+ """
105+ Container = reactpy .reactjs .component_from_file (
106+ JS_FIXTURES_DIR / "nest-custom-under-web.js" , "Container" , name = "nest-custom-under-web"
107+ )
108+
109+ @reactpy .component
110+ def CustomComponent ():
111+ return reactpy .html .div (reactpy .html .h1 ({"id" : "my-header" }, "Header 1" ))
112+
113+ await display .show (lambda : Container (CustomComponent ()))
114+
115+ element = await display .page .wait_for_selector ("#my-header" , state = "attached" )
116+ assert await element .inner_text () == "Header 1"
Original file line number Diff line number Diff line change 1+ """
2+ THESE ARE TESTS FOR THE LEGACY API. SEE tests/test_reactjs/* FOR THE NEW API TESTS.
3+ THE CONTENTS OF THIS MODULE WILL BE MIGRATED OR DELETED ONCE THE LEGACY API IS REMOVED.
4+ """
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- # THESE ARE TESTS FOR THE LEGACY API. SEE tests/test_reactjs/* FOR THE NEW API TESTS.
2- # THIS MODULE WILL BE MIGRATED OR DELETED ONCE THE LEGACY API IS REMOVED.
1+ """
2+ THESE ARE TESTS FOR THE LEGACY API. SEE tests/test_reactjs/* FOR THE NEW API TESTS.
3+ THE CONTENTS OF THIS MODULE WILL BE MIGRATED OR DELETED ONCE THE LEGACY API IS REMOVED.
4+ """
35from pathlib import Path
46
57import pytest
@@ -563,32 +565,3 @@ async def test_module_without_bind(display: DisplayFixture):
563565 "#my-generic-component" , state = "attached"
564566 )
565567 assert await element .inner_text () == "Hello World"
566-
567- async def test_nest_custom_component_under_web_component (display : DisplayFixture ):
568- """
569- Fix https://github.com/reactive-python/reactpy/discussions/1323
570-
571- Custom components (i.e those wrapped in the component decorator) were not able to
572- be nested under web components.
573-
574- """
575- module = reactpy .reactjs .file_to_module (
576- "nest-custom-under-web" , JS_FIXTURES_DIR / "nest-custom-under-web.js"
577- )
578- Container = reactpy .reactjs .module_to_vdom (module , "Container" )
579-
580- @reactpy .component
581- def CustomComponent ():
582- return reactpy .html .div (
583- reactpy .html .h1 ({"id" : "my-header" }, "Header 1" )
584- )
585- await display .show (
586- lambda : Container (
587- CustomComponent ()
588- )
589- )
590-
591- element = await display .page .wait_for_selector (
592- "#my-header" , state = "attached"
593- )
594- assert await element .inner_text () == "Header 1"
You can’t perform that action at this time.
0 commit comments