Skip to content

Commit d2f9faf

Browse files
authored
Pass environment to resolved ViewReference content (#1283)
1 parent da7a79b commit d2f9faf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/LiveViewNative/Stylesheets/ViewReference.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ import LiveViewNativeCore
88
public struct ViewReference: ParseableModifierValue {
99
let value: [String]
1010

11+
@MainActor
1112
public func resolve<R: RootRegistry>(on element: ElementNode, in context: LiveContext<R>) -> some View {
1213
ForEach(value, id: \.self) {
1314
context.buildChildren(of: element, forTemplate: $0)
1415
}
16+
.transformEnvironment(\.self) { environment in
17+
if environment.anyLiveContextStorage == nil {
18+
environment.anyLiveContextStorage = context.storage
19+
}
20+
if environment.coordinatorEnvironment == nil {
21+
environment.coordinatorEnvironment = .init(context.coordinator, document: context.coordinator.document!)
22+
}
23+
}
1524
}
1625

1726
public static func parser(in context: ParseableModifierContext) -> some Parser<Substring.UTF8View, Self> {

0 commit comments

Comments
 (0)