Skip to content

Commit

Permalink
Merge pull request #43 from cybozu/revert-weak-reference
Browse files Browse the repository at this point in the history
Revert #40
  • Loading branch information
Kyome22 authored Jan 22, 2025
2 parents 92018cb + 7e01af5 commit 65d9786
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Sources/WebUI/WebView+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension WebView: View {
@MainActor
private func makeView() -> Remakeable<EnhancedWKWebView> {
let webView = Remakeable<EnhancedWKWebView> {
let wrappedView = EnhancedWKWebView(frame: .zero, configuration: parent.configuration ?? .init())
let wrappedView = EnhancedWKWebView(frame: .zero, configuration: parent.configuration)
parent.applyModifiers(to: wrappedView)
return wrappedView
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/WebUI/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import WebKit
/// ```
@available(iOS 16.4, macOS 13.3, *)
public struct WebView {
weak var configuration: WKWebViewConfiguration?
let configuration: WKWebViewConfiguration

private let initialRequest: URLRequest?

private weak var uiDelegate: (any WKUIDelegate)?
private weak var navigationDelegate: (any WKNavigationDelegate)?
private var uiDelegate: (any WKUIDelegate)?
private var navigationDelegate: (any WKNavigationDelegate)?
private var isInspectable = false
private var allowsBackForwardNavigationGestures = false
private var allowsLinkPreview = true
Expand All @@ -30,7 +30,7 @@ public struct WebView {
/// - request: The initial request specifying the URL to load.
/// - configuration: The configuration for the new web view.
@MainActor
public init(request: URLRequest? = nil, configuration: WKWebViewConfiguration? = nil) {
public init(request: URLRequest? = nil, configuration: WKWebViewConfiguration = .init()) {
self.initialRequest = request
self.configuration = configuration
}
Expand Down
26 changes: 0 additions & 26 deletions Tests/WebUITests/WebViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
import XCTest

final class WebViewTests: XCTestCase {
@MainActor
func test_configuration_is_weakly_referenced() {
var configuration: WebViewConfigurationMock? = .init()
let sut = WebView(configuration: configuration)
configuration = nil
XCTAssertNil(sut.configuration)
}

@MainActor
func test_applyModifiers_uiDelegate() {
let uiDelegateMock = UIDelegateMock()
Expand All @@ -19,15 +11,6 @@ final class WebViewTests: XCTestCase {
XCTAssertTrue(uiDelegateMock === webViewMock.uiDelegate)
}

@MainActor
func test_uiDelegate_is_weakly_referenced() {
var sut = WebView()
let actual = weaklyScope(UIDelegateMock()) {
sut = sut.uiDelegate($0)
}
XCTAssertNil(actual)
}

@MainActor
func test_applyModifiers_navigationDelegate() {
let navigationDelegateMock = NavigationDelegateMock()
Expand All @@ -37,15 +20,6 @@ final class WebViewTests: XCTestCase {
XCTAssertTrue(navigationDelegateMock === webViewMock.navigationDelegateProxy.delegate)
}

@MainActor
func test_navigationDelegate_is_weakly_referenced() {
var sut = WebView()
let actual = weaklyScope(NavigationDelegateMock()) {
sut = sut.navigationDelegate($0)
}
XCTAssertNil(actual)
}

@MainActor
func test_applyModifiers_isInspectable() {
let sut = WebView().allowsInspectable(true)
Expand Down
15 changes: 0 additions & 15 deletions Tests/WebUITests/XCTestCase+Extension.swift

This file was deleted.

0 comments on commit 65d9786

Please sign in to comment.