htmlvdom

package module
v0.0.0-...-b87d736 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2022 License: MIT Imports: 10 Imported by: 0

README

htmlvdom

Virtual DOM

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAttributeNotFound = fmt.Errorf("attribute not found")

Functions

func BytesToString

func BytesToString(b []byte) string

func StringToBytes

func StringToBytes(s string) []byte

Types

type CreateInfo

type CreateInfo struct {
	TagName string
	NewID   uint64
}

type DeleteInfo

type DeleteInfo struct {
	ID uint64
}

type Difference

type Difference struct {
	Diff []*Operation
}

func Diff

func Diff(a, b *Element) *Difference

type Element

type Element struct {
	TagName  string
	Attrs    map[string]string
	Children []*Element
	Value    string
	ID       uint64
	XXHash   uint64
	// contains filtered or unexported fields
}

func CreateElement

func CreateElement(tagName string) *Element

func CreateTextNode

func CreateTextNode(text string) *Element

func (*Element) AppendChild

func (el *Element) AppendChild(child *Element)

func (*Element) Clone

func (el *Element) Clone(deep bool) *Element

func (*Element) Destory

func (el *Element) Destory()

func (*Element) GetAttribute

func (el *Element) GetAttribute(key string) (string, error)

func (*Element) GetNewID

func (el *Element) GetNewID() uint64

func (*Element) HasChildNodes

func (el *Element) HasChildNodes() bool

func (*Element) Hash

func (el *Element) Hash()

func (*Element) IndexChild

func (el *Element) IndexChild(child *Element) (int, bool)

func (*Element) Init

func (el *Element) Init()

func (*Element) InitHash

func (el *Element) InitHash()

func (*Element) Remove

func (el *Element) Remove()

func (*Element) RemoveAttribute

func (el *Element) RemoveAttribute(key string)

func (*Element) RemoveChild

func (el *Element) RemoveChild(child *Element)

func (*Element) ReplaceChild

func (el *Element) ReplaceChild(oldChild, newChild *Element)

func (*Element) SetAttribute

func (el *Element) SetAttribute(key, value string)

func (*Element) SetInnerText

func (el *Element) SetInnerText(text string)

func (*Element) String

func (el *Element) String() string

type Operation

type Operation struct {
	Type   OperationType
	Target uint64

	CreateInfo          *CreateInfo          `json:"CreateInfo,omitempty"`
	SetAttributeInfo    *SetAttributeInfo    `json:"SetAttributeInfo,omitempty"`
	DeleteInfo          *DeleteInfo          `json:"DeleteInfo,omitempty"`
	RemoveAttributeInfo *RemoveAttributeInfo `json:"RemoveAttributeInfo,omitempty"`
	SetValueInfo        *SetValueInfo        `json:"SetValueInfo,omitempty"`
}

type OperationType

type OperationType byte
const (
	OP_CREATE_ELEMENT OperationType = iota
	OP_CREATE_TEXT
	OP_SET_VALUE
	OP_SET_ATTRIBUTE
	OP_REMOVE_ATTRIBUTE
	OP_APPEND_CHILD
	OP_REMOVE_CHILD
	OP_REPLACE_CHILD
)

type RemoveAttributeInfo

type RemoveAttributeInfo struct {
	Key string
}

type SetAttributeInfo

type SetAttributeInfo struct {
	Key string
	Val string
}

type SetValueInfo

type SetValueInfo struct {
	Val string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL