Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _targetRef and _domRef modifiers #240

Merged
merged 5 commits into from
Aug 2, 2020
Merged

Add _targetRef and _domRef modifiers #240

merged 5 commits into from
Aug 2, 2020

Conversation

MaxDesiatov
Copy link
Collaborator

@MaxDesiatov MaxDesiatov commented Aug 2, 2020

Resolves partially #231. _targetRef is a modifier that can be used by any renderer, while _domRef is an adaptation of that for DOMRenderer. Both are underscored as they are not available in SwiftUI, and also their stability is currently not so well known to us, we may consider changing this API in the future.

Example use:

struct DOMRefDemo: View {
  @State var button: JSObjectRef?

  var body: some View {
    Button("Click me") {
      button?.innerHTML = "This text was set directly through a DOM reference"
    }._domRef($button)
  }
}

I've also fixed all known line length warnings in this PR.

@MaxDesiatov MaxDesiatov added enhancement New feature or request API design API design and prototyping is needed labels Aug 2, 2020
carson-katri
carson-katri previously approved these changes Aug 2, 2020
@carson-katri
Copy link
Member

Awesome 👍

@MaxDesiatov MaxDesiatov requested a review from j-f1 August 2, 2020 20:19
@MaxDesiatov MaxDesiatov merged commit b93be40 into main Aug 2, 2020
@MaxDesiatov MaxDesiatov deleted the dom-ref-modifier branch August 2, 2020 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API design API design and prototyping is needed enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants