2024-07-23 22:16:53 +02:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2024-11-04 21:52:36 +01:00
|
|
|
type ComponentImpl struct {
|
2024-10-17 23:50:36 +02:00
|
|
|
WaveId string
|
2024-07-23 22:16:53 +02:00
|
|
|
Tag string
|
|
|
|
Key string
|
2024-10-17 23:50:36 +02:00
|
|
|
Elem *VDomElem
|
2024-07-23 22:16:53 +02:00
|
|
|
Mounted bool
|
|
|
|
|
|
|
|
// hooks
|
|
|
|
Hooks []*Hook
|
|
|
|
|
|
|
|
// #text component
|
|
|
|
Text string
|
|
|
|
|
|
|
|
// base component -- vdom, wave elem, or #fragment
|
2024-11-04 21:52:36 +01:00
|
|
|
Children []*ComponentImpl
|
2024-07-23 22:16:53 +02:00
|
|
|
|
|
|
|
// component -> component
|
2024-11-04 21:52:36 +01:00
|
|
|
Comp *ComponentImpl
|
2024-07-23 22:16:53 +02:00
|
|
|
}
|
|
|
|
|
2024-11-04 21:52:36 +01:00
|
|
|
func (c *ComponentImpl) compMatch(tag string, key string) bool {
|
2024-07-23 22:16:53 +02:00
|
|
|
if c == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return c.Tag == tag && c.Key == key
|
|
|
|
}
|