waveterm/pkg/vdom/vdom_comp.go

41 lines
719 B
Go
Raw Normal View History

// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
package vdom
// so components either render to another component (or fragment)
// or to a base element (text or vdom). base elements can then render children
type ChildKey struct {
Tag string
Idx int
Key string
}
type Component struct {
2024-10-17 23:50:36 +02:00
WaveId string
Tag string
Key string
2024-10-17 23:50:36 +02:00
Elem *VDomElem
Mounted bool
// hooks
Hooks []*Hook
// #text component
Text string
// base component -- vdom, wave elem, or #fragment
Children []*Component
// component -> component
Comp *Component
}
func (c *Component) compMatch(tag string, key string) bool {
if c == nil {
return false
}
return c.Tag == tag && c.Key == key
}