File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
assets/js/phoenix_live_view Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -2176,7 +2176,7 @@ export default class View {
21762176 }
21772177
21782178 ownsElement ( el ) {
2179- let parentViewEl = el . closest ( PHX_VIEW_SELECTOR ) ;
2179+ let parentViewEl = DOM . closestViewEl ( el ) ;
21802180 return (
21812181 el . getAttribute ( PHX_PARENT_ID ) === this . id ||
21822182 ( parentViewEl && parentViewEl . id === this . id ) ||
Original file line number Diff line number Diff line change @@ -60,6 +60,11 @@ defmodule Phoenix.LiveViewTest.E2E.PortalLive do
6060 this . liveSocket . execJS ( this . el , this . el . dataset . hide ) ;
6161 this. cleanup && this . cleanup ( ) ;
6262 } ,
63+ } ,
64+ InsidePortal: {
65+ mounted ( ) {
66+ this . js ( ) . setAttribute ( this . el , "data-portalhook-mounted" , "true" ) ;
67+ }
6368 }
6469 }
6570 } )
@@ -145,6 +150,8 @@ defmodule Phoenix.LiveViewTest.E2E.PortalLive do
145150 < p > DOM patching works as expected: { @ count } </ p >
146151 < . button phx-click = { JS . patch ( "/portal?param=#{ @ param_next } " ) } > Patch this LiveView</ . button >
147152 </ . modal >
153+
154+ < div id = "hook-test " phx-hook = "InsidePortal " > This should get a data attribute</ div >
148155 </ . portal >
149156
150157 < . portal id = "portal-source-2 " target = "#app-portal " >
Original file line number Diff line number Diff line change @@ -103,3 +103,14 @@ test("tooltip example", async ({ page }) => {
103103 await expect ( page . locator ( "#tooltip-example-portal" ) ) . toBeHidden ( ) ;
104104 await expect ( page . locator ( "#tooltip-example-no-portal" ) ) . toBeVisible ( ) ;
105105} ) ;
106+
107+ test ( "teleported hook works correctly" , async ( { page } ) => {
108+ // https://github.com/phoenixframework/phoenix_live_view/issues/3950
109+ await page . goto ( "/portal?tick=false" ) ;
110+ await syncLV ( page ) ;
111+
112+ await expect ( page . locator ( "#hook-test" ) ) . toHaveAttribute (
113+ "data-portalhook-mounted" ,
114+ "true" ,
115+ ) ;
116+ } ) ;
You can’t perform that action at this time.
0 commit comments