Documentation ¶
Index ¶
- func CreateElement(elementName string) interface{}
- func Define(f interface{}) error
- func MustDefine(f interface{})
- type CustomElement
- type Element
- func (e *Element) AddEventListener(eventName string, f func(*Event))
- func (e *Element) AdoptedCallback(oldDocument, newDocument interface{})
- func (e *Element) AttributeChangedCallback(attributeName string, oldValue string, newValue string, namespace string)
- func (e *Element) ConnectedCallback()
- func (e *Element) DisconnectedCallback()
- func (e *Element) DispatchEvent(ce *Event)
- func (e *Element) SetTemplate(template Template)
- type Event
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateElement ¶
func CreateElement(elementName string) interface{}
CreateElement creates a new instance of an element that can be type asserted to custom element
func Define ¶
func Define(f interface{}) error
Define registers an new custom element takes the constructor of the element func()*YourElemType element is registered under the name converted from your element type (YourElemType -> your-elem-type)
func MustDefine ¶
func MustDefine(f interface{})
MustDefine registers an new custom element takes the constructor of the element func()*YourElemType element is registered under the name converted from your element type (YourElemType -> your-elem-type) if an error occures it panics
Types ¶
type CustomElement ¶
type CustomElement interface { ConnectedCallback() DisconnectedCallback() AttributeChangedCallback(attributeName string, oldValue string, newValue string, namespace string) AdoptedCallback(oldDocument, newDocument interface{}) DispatchEvent(customEvent *Event) }
CustomElement the interface to create the CustomElement
type Element ¶
type Element struct { *js.Object ObjValue reflect.Value //custom element struct type Children map[string]*js.Object // contains filtered or unexported fields }
Element wrapper for the HTML element
func (*Element) AddEventListener ¶
AddEventListener is an wrapper for the js addEventListener
func (*Element) AdoptedCallback ¶
func (e *Element) AdoptedCallback(oldDocument, newDocument interface{})
AdoptedCallback ...
func (*Element) AttributeChangedCallback ¶
func (e *Element) AttributeChangedCallback(attributeName string, oldValue string, newValue string, namespace string)
AttributeChangedCallback ...
func (*Element) ConnectedCallback ¶
func (e *Element) ConnectedCallback()
ConnectedCallback called when the element is attached to the DOM
func (*Element) DisconnectedCallback ¶
func (e *Element) DisconnectedCallback()
DisconnectedCallback called when the element is dettached from the DOM
func (*Element) DispatchEvent ¶
DispatchEvent dispatches an Event at the specified EventTarget, invoking the affected EventListeners in the appropriate order
func (*Element) SetTemplate ¶
SetTemplate sets this element's template, must be called in own element's constructor, before connectedCallback
type Event ¶
type Event struct { *js.Object //A Boolean indicating whether the event bubbles up through the DOM or not. Bubbles bool `js:"bubbles"` //A Boolean indicating whether the event is cancelable. Cancelable bool `js:"cancelable"` //A Boolean value indicating whether or not the event can bubble across the boundary between the shadow DOM and the regular DOM. Composed bool `js:"composed"` //A reference to the currently registered target for the event. //This is the object to which the event is currently slated to be sent to; //it's possible this has been changed along the way through retargeting. CurrentTarget *js.Object `js:"currentTarget"` //An Array of DOM Nodes through which the event has bubbled. DeepPath []*js.Object `js:"deepPath"` //Indicates whether or not event.preventDefault() has been called on the event. DefaultPrevented bool `js:"defaultPrevented"` //Any data passed when initializing the event Detail map[string]interface{} `js:"detail"` //Indicates which phase of the event flow is being processed. EventPhase int `js:"eventPhase"` //A reference to the target to which the event was originally dispatched. Target *js.Object `js:"target"` //The time at which the event was created, in milliseconds. //By specification, this value is time since epoch, but in reality browsers' definitions vary; //in addition, work is underway to change this to be a DOMHighResTimeStamp instead. TimeStamp time.Time `js:"timeStamp"` //The name of the event (case-insensitive). Type string `js:"type"` //Indicates whether not the event was initiated by the browser (after a user click for instance) //or by a script (using an event creation method, like event.initEvent) IsTrusted bool `js:"isTrusted"` }
Event represents any event which takes place in the DOM
func (*Event) StopPropagation ¶
func (e *Event) StopPropagation()
StopPropagation prevents further propagation of the current event in the capturing and bubbling phases