-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
Applying markup with Text() panics often #199
Comments
Agreed, we should be producing a clean panic here and documenting this or refusing to accept
WDYT @pdf ? |
I think I'd be fine with just changing the signature to |
Yeah, or we could always offer an 👍 to just changing signature to |
Sounds good to me as well, to change the signature of Text(). There's still the issue of what to do when Apply(h) is called on a *HTML that's a text node. I make my own types that implement Applyer quite often. There's no way to tell in that situation if a *HTML is a text node (without being hacky). Perhaps we could add a (*HTML).IsText() method? |
@bzub Could you elaborate / provide examples of |
I'll have a concrete example that I'm happy with in a few days, hopefully. So I'll elaborate with a simple example for now. I've created types that satisfy both Going beyond this, in my experience the web library components I'm trying to implement in Vecty often have child elements that each need special markup applied as well. So my idea was to make each of those building blocks as types that satisfy Here's an HTML example. Here's a basic render example. The func (c *ApplyerComponent) Render() vecty.ComponentOrHTML {
return elem.Div(
vecty.Markup(
c,
c.UserSuppliedMarkup
)
// Children
&ChildComponent{Label: "Child Component 1"},
&ChildComponent{Label: "Child Component 2"},
)
} |
Using an Applyer that isn't compatable with a Text Node doesn't appear to be handled currently.
Simple example:
Result:
Code:
https://github.com/gopherjs/vecty/blob/1d629507357c2e861fbc2b7cf1553c1cb0789399/dom.go#L1251
The text was updated successfully, but these errors were encountered: