Web API package for use when compling Go to WASM
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Brett Langdon f392b85950
have interfaces implement parent iface functions
7 years ago
console Update primitive type mapping 7 years ago
css Update primitive type mapping 7 years ago
document Add DOMParser support and partial members 7 years ago
example Add readme and examples 7 years ago
generate have interfaces implement parent iface functions 7 years ago
window Add DOMParser support and partial members 7 years ago
Makefile get global namespace packages together 7 years ago
README.md fix code fence 7 years ago
abortcontroller.go Add support for interface constructor 7 years ago
abortsignal.go have interfaces implement parent iface functions 7 years ago
abstractrange.go Add support for interface constructor 7 years ago
applicationcache.go have interfaces implement parent iface functions 7 years ago
arraybuffer.go get global namespace packages together 7 years ago
arraybufferview.go get global namespace packages together 7 years ago
attr.go have interfaces implement parent iface functions 7 years ago
audiotrack.go Add support for interface constructor 7 years ago
audiotracklist.go have interfaces implement parent iface functions 7 years ago
barprop.go Add support for interface constructor 7 years ago
beforeunloadevent.go have interfaces implement parent iface functions 7 years ago
binarytype.go get global namespace packages together 7 years ago
blob.go Add support for interface constructor 7 years ago
blobcallback.go get global namespace packages together 7 years ago
blobpart.go get global namespace packages together 7 years ago
bodyinit.go get global namespace packages together 7 years ago
broadcastchannel.go have interfaces implement parent iface functions 7 years ago
buffersource.go get global namespace packages together 7 years ago
callback.go get global namespace packages together 7 years ago
canplaytyperesult.go get global namespace packages together 7 years ago
canvasdirection.go get global namespace packages together 7 years ago
canvasfillrule.go get global namespace packages together 7 years ago
canvasgradient.go Add support for interface constructor 7 years ago
canvasimagesource.go get global namespace packages together 7 years ago
canvaslinecap.go get global namespace packages together 7 years ago
canvaslinejoin.go get global namespace packages together 7 years ago
canvaspattern.go Add support for interface constructor 7 years ago
canvasrenderingcontext2d.go Add support for interface constructor 7 years ago
canvastextalign.go get global namespace packages together 7 years ago
canvastextbaseline.go get global namespace packages together 7 years ago
cdatasection.go have interfaces implement parent iface functions 7 years ago
characterdata.go have interfaces implement parent iface functions 7 years ago
closeevent.go have interfaces implement parent iface functions 7 years ago
colorspaceconversion.go get global namespace packages together 7 years ago
comment.go have interfaces implement parent iface functions 7 years ago
cssgroupingrule.go have interfaces implement parent iface functions 7 years ago
cssimportrule.go have interfaces implement parent iface functions 7 years ago
cssmarginrule.go have interfaces implement parent iface functions 7 years ago
cssnamespacerule.go have interfaces implement parent iface functions 7 years ago
csspagerule.go have interfaces implement parent iface functions 7 years ago
cssrule.go Add support for interface constructor 7 years ago
cssrulelist.go Add support for interface constructor 7 years ago
cssstyledeclaration.go Add support for interface constructor 7 years ago
cssstylerule.go have interfaces implement parent iface functions 7 years ago
cssstylesheet.go have interfaces implement parent iface functions 7 years ago
customelementconstructor.go Fix typedef callback definitions 7 years ago
customelementregistry.go Add support for interface constructor 7 years ago
customevent.go have interfaces implement parent iface functions 7 years ago
datatransfer.go Add support for interface constructor 7 years ago
datatransferitem.go Add support for interface constructor 7 years ago
datatransferitemlist.go Add support for interface constructor 7 years ago
dedicatedworkerglobalscope.go have interfaces implement parent iface functions 7 years ago
document.go have interfaces implement parent iface functions 7 years ago
documentfragment.go have interfaces implement parent iface functions 7 years ago
documentreadystate.go get global namespace packages together 7 years ago
documenttype.go have interfaces implement parent iface functions 7 years ago
domexception.go Add support for interface constructor 7 years ago
domhighrestimestamp.go get global namespace packages together 7 years ago
domimplementation.go Add support for interface constructor 7 years ago
dommatrix.go have interfaces implement parent iface functions 7 years ago
dommatrixreadonly.go Add support for interface constructor 7 years ago
domparser.go Add support for interface constructor 7 years ago
dompoint.go have interfaces implement parent iface functions 7 years ago
dompointreadonly.go Add support for interface constructor 7 years ago
domquad.go Add support for interface constructor 7 years ago
domrect.go have interfaces implement parent iface functions 7 years ago
domrectlist.go Add support for interface constructor 7 years ago
domrectreadonly.go Add support for interface constructor 7 years ago
domstringlist.go Add support for interface constructor 7 years ago
domstringmap.go Add support for interface constructor 7 years ago
domtimestamp.go Update primitive type mapping 7 years ago
domtokenlist.go Add support for interface constructor 7 years ago
dragevent.go Add support for interface constructor 7 years ago
element.go have interfaces implement parent iface functions 7 years ago
endingtype.go get global namespace packages together 7 years ago
errorevent.go have interfaces implement parent iface functions 7 years ago
event.go Add support for interface constructor 7 years ago
eventhandler.go Fix typedef callback definitions 7 years ago
eventhandlernonnull.go Fix typedef callback definitions 7 years ago
eventlistener.go get global namespace packages together 7 years ago
eventsource.go have interfaces implement parent iface functions 7 years ago
eventtarget.go Add support for interface constructor 7 years ago
example.go Add support for interface constructor 7 years ago
external.go Add support for interface constructor 7 years ago
file.go have interfaces implement parent iface functions 7 years ago
filelist.go Add support for interface constructor 7 years ago
filereader.go have interfaces implement parent iface functions 7 years ago
filereadersync.go Add support for interface constructor 7 years ago
float32array.go get global namespace packages together 7 years ago
float64array.go get global namespace packages together 7 years ago
formdata.go Add support for interface constructor 7 years ago
formdataentryvalue.go get global namespace packages together 7 years ago
framerequestcallback.go get global namespace packages together 7 years ago
functionstringcallback.go get global namespace packages together 7 years ago
go.mod Update primitive type mapping 7 years ago
hashchangeevent.go have interfaces implement parent iface functions 7 years ago
headers.go Add support for interface constructor 7 years ago
headersinit.go get global namespace packages together 7 years ago
history.go Add support for interface constructor 7 years ago
htmlallcollection.go Add support for interface constructor 7 years ago
htmlanchorelement.go have interfaces implement parent iface functions 7 years ago
htmlareaelement.go have interfaces implement parent iface functions 7 years ago
htmlaudioelement.go have interfaces implement parent iface functions 7 years ago
htmlbaseelement.go have interfaces implement parent iface functions 7 years ago
htmlbodyelement.go have interfaces implement parent iface functions 7 years ago
htmlbrelement.go have interfaces implement parent iface functions 7 years ago
htmlbuttonelement.go have interfaces implement parent iface functions 7 years ago
htmlcanvaselement.go have interfaces implement parent iface functions 7 years ago
htmlcollection.go Add support for interface constructor 7 years ago
htmldataelement.go have interfaces implement parent iface functions 7 years ago
htmldatalistelement.go have interfaces implement parent iface functions 7 years ago
htmldetailselement.go have interfaces implement parent iface functions 7 years ago
htmldialogelement.go have interfaces implement parent iface functions 7 years ago
htmldirectoryelement.go have interfaces implement parent iface functions 7 years ago
htmldivelement.go have interfaces implement parent iface functions 7 years ago
htmldlistelement.go have interfaces implement parent iface functions 7 years ago
htmlelement.go have interfaces implement parent iface functions 7 years ago
htmlembedelement.go have interfaces implement parent iface functions 7 years ago
htmlfieldsetelement.go have interfaces implement parent iface functions 7 years ago
htmlfontelement.go have interfaces implement parent iface functions 7 years ago
htmlformcontrolscollection.go have interfaces implement parent iface functions 7 years ago
htmlformelement.go have interfaces implement parent iface functions 7 years ago
htmlframeelement.go have interfaces implement parent iface functions 7 years ago
htmlframesetelement.go have interfaces implement parent iface functions 7 years ago
htmlheadelement.go have interfaces implement parent iface functions 7 years ago
htmlheadingelement.go have interfaces implement parent iface functions 7 years ago
htmlhrelement.go have interfaces implement parent iface functions 7 years ago
htmlhtmlelement.go have interfaces implement parent iface functions 7 years ago
htmliframeelement.go have interfaces implement parent iface functions 7 years ago
htmlimageelement.go have interfaces implement parent iface functions 7 years ago
htmlinputelement.go have interfaces implement parent iface functions 7 years ago
htmllabelelement.go have interfaces implement parent iface functions 7 years ago
htmllegendelement.go have interfaces implement parent iface functions 7 years ago
htmllielement.go have interfaces implement parent iface functions 7 years ago
htmllinkelement.go have interfaces implement parent iface functions 7 years ago
htmlmapelement.go have interfaces implement parent iface functions 7 years ago
htmlmarqueeelement.go have interfaces implement parent iface functions 7 years ago
htmlmediaelement.go have interfaces implement parent iface functions 7 years ago
htmlmenuelement.go have interfaces implement parent iface functions 7 years ago
htmlmetaelement.go have interfaces implement parent iface functions 7 years ago
htmlmeterelement.go have interfaces implement parent iface functions 7 years ago
htmlmodelement.go have interfaces implement parent iface functions 7 years ago
htmlobjectelement.go have interfaces implement parent iface functions 7 years ago
htmlolistelement.go have interfaces implement parent iface functions 7 years ago
htmloptgroupelement.go have interfaces implement parent iface functions 7 years ago
htmloptionelement.go have interfaces implement parent iface functions 7 years ago
htmloptionscollection.go have interfaces implement parent iface functions 7 years ago
htmlorsvgimageelement.go get global namespace packages together 7 years ago
htmlorsvgscriptelement.go get global namespace packages together 7 years ago
htmloutputelement.go have interfaces implement parent iface functions 7 years ago
htmlparagraphelement.go have interfaces implement parent iface functions 7 years ago
htmlparamelement.go have interfaces implement parent iface functions 7 years ago
htmlpictureelement.go have interfaces implement parent iface functions 7 years ago
htmlpreelement.go have interfaces implement parent iface functions 7 years ago
htmlprogresselement.go have interfaces implement parent iface functions 7 years ago
htmlquoteelement.go have interfaces implement parent iface functions 7 years ago
htmlscriptelement.go have interfaces implement parent iface functions 7 years ago
htmlselectelement.go have interfaces implement parent iface functions 7 years ago
htmlslotelement.go have interfaces implement parent iface functions 7 years ago
htmlsourceelement.go have interfaces implement parent iface functions 7 years ago
htmlspanelement.go have interfaces implement parent iface functions 7 years ago
htmlstyleelement.go have interfaces implement parent iface functions 7 years ago
htmltablecaptionelement.go have interfaces implement parent iface functions 7 years ago
htmltablecellelement.go have interfaces implement parent iface functions 7 years ago
htmltablecolelement.go have interfaces implement parent iface functions 7 years ago
htmltableelement.go have interfaces implement parent iface functions 7 years ago
htmltablerowelement.go have interfaces implement parent iface functions 7 years ago
htmltablesectionelement.go have interfaces implement parent iface functions 7 years ago
htmltemplateelement.go have interfaces implement parent iface functions 7 years ago
htmltextareaelement.go have interfaces implement parent iface functions 7 years ago
htmltimeelement.go have interfaces implement parent iface functions 7 years ago
htmltitleelement.go have interfaces implement parent iface functions 7 years ago
htmltrackelement.go have interfaces implement parent iface functions 7 years ago
htmlulistelement.go have interfaces implement parent iface functions 7 years ago
htmlunknownelement.go have interfaces implement parent iface functions 7 years ago
htmlvideoelement.go have interfaces implement parent iface functions 7 years ago
imagebitmap.go Add support for interface constructor 7 years ago
imagebitmaprenderingcontext.go Add support for interface constructor 7 years ago
imagebitmapsource.go get global namespace packages together 7 years ago
imagedata.go Add support for interface constructor 7 years ago
imageorientation.go get global namespace packages together 7 years ago
imagesmoothingquality.go get global namespace packages together 7 years ago
location.go Add support for interface constructor 7 years ago
loop.go Add dom.Loop helper struct 7 years ago
mediaerror.go Add support for interface constructor 7 years ago
medialist.go Add support for interface constructor 7 years ago
mediaprovider.go get global namespace packages together 7 years ago
messagechannel.go Add support for interface constructor 7 years ago
messageevent.go have interfaces implement parent iface functions 7 years ago
messageeventsource.go get global namespace packages together 7 years ago
messageport.go have interfaces implement parent iface functions 7 years ago
mimetype.go Add support for interface constructor 7 years ago
mimetypearray.go Add support for interface constructor 7 years ago
mutationcallback.go get global namespace packages together 7 years ago
mutationobserver.go Add support for interface constructor 7 years ago
mutationrecord.go Add support for interface constructor 7 years ago
namednodemap.go Add support for interface constructor 7 years ago
navigator.go Add support for interface constructor 7 years ago
node.go have interfaces implement parent iface functions 7 years ago
nodefilter.go Update primitive type mapping 7 years ago
nodeiterator.go Add support for interface constructor 7 years ago
nodelist.go Add support for interface constructor 7 years ago
offscreencanvas.go have interfaces implement parent iface functions 7 years ago
offscreencanvasrenderingcontext2d.go Add support for interface constructor 7 years ago
offscreenrenderingcontext.go get global namespace packages together 7 years ago
offscreenrenderingcontextid.go get global namespace packages together 7 years ago
onbeforeunloadeventhandler.go Fix typedef callback definitions 7 years ago
onbeforeunloadeventhandlernonnull.go Fix typedef callback definitions 7 years ago
onerroreventhandler.go Fix typedef callback definitions 7 years ago
onerroreventhandlernonnull.go Fix typedef callback definitions 7 years ago
pagetransitionevent.go have interfaces implement parent iface functions 7 years ago
path2d.go Add support for interface constructor 7 years ago
performance.go have interfaces implement parent iface functions 7 years ago
plugin.go Add support for interface constructor 7 years ago
pluginarray.go Add support for interface constructor 7 years ago
popstateevent.go have interfaces implement parent iface functions 7 years ago
premultiplyalpha.go get global namespace packages together 7 years ago
processinginstruction.go have interfaces implement parent iface functions 7 years ago
progressevent.go have interfaces implement parent iface functions 7 years ago
promiserejectionevent.go have interfaces implement parent iface functions 7 years ago
radionodelist.go have interfaces implement parent iface functions 7 years ago
range.go have interfaces implement parent iface functions 7 years ago
referrerpolicy.go get global namespace packages together 7 years ago
renderingcontext.go get global namespace packages together 7 years ago
request.go Add support for interface constructor 7 years ago
requestcache.go get global namespace packages together 7 years ago
requestcredentials.go get global namespace packages together 7 years ago
requestdestination.go get global namespace packages together 7 years ago
requestinfo.go get global namespace packages together 7 years ago
requestmode.go get global namespace packages together 7 years ago
requestredirect.go get global namespace packages together 7 years ago
resizequality.go get global namespace packages together 7 years ago
response.go Add support for interface constructor 7 years ago
responsetype.go get global namespace packages together 7 years ago
scrollrestoration.go get global namespace packages together 7 years ago
selectionmode.go get global namespace packages together 7 years ago
shadowroot.go have interfaces implement parent iface functions 7 years ago
shadowrootmode.go get global namespace packages together 7 years ago
sharedworker.go have interfaces implement parent iface functions 7 years ago
sharedworkerglobalscope.go have interfaces implement parent iface functions 7 years ago
staticrange.go have interfaces implement parent iface functions 7 years ago
storage.go Add support for interface constructor 7 years ago
storageevent.go have interfaces implement parent iface functions 7 years ago
storagemanager.go Add support for interface constructor 7 years ago
stylesheet.go Add support for interface constructor 7 years ago
stylesheetlist.go Add support for interface constructor 7 years ago
supportedtype.go Add DOMParser support and partial members 7 years ago
text.go have interfaces implement parent iface functions 7 years ago
textdecoder.go Add support for interface constructor 7 years ago
textdecoderstream.go Add support for interface constructor 7 years ago
textencoder.go Add support for interface constructor 7 years ago
textencoderstream.go Add support for interface constructor 7 years ago
textmetrics.go Add support for interface constructor 7 years ago
texttrack.go have interfaces implement parent iface functions 7 years ago
texttrackcue.go have interfaces implement parent iface functions 7 years ago
texttrackcuelist.go Add support for interface constructor 7 years ago
texttrackkind.go get global namespace packages together 7 years ago
texttracklist.go have interfaces implement parent iface functions 7 years ago
texttrackmode.go get global namespace packages together 7 years ago
timeranges.go Add support for interface constructor 7 years ago
timerhandler.go get global namespace packages together 7 years ago
trackevent.go have interfaces implement parent iface functions 7 years ago
treewalker.go Add support for interface constructor 7 years ago
uint8array.go get global namespace packages together 7 years ago
uint8clampedarray.go get global namespace packages together 7 years ago
url.go Add support for interface constructor 7 years ago
urlsearchparams.go Add support for interface constructor 7 years ago
validitystate.go Add support for interface constructor 7 years ago
value.go Add Is<Type> helpers 7 years ago
videotrack.go Add support for interface constructor 7 years ago
videotracklist.go have interfaces implement parent iface functions 7 years ago
websocket.go have interfaces implement parent iface functions 7 years ago
window.go have interfaces implement parent iface functions 7 years ago
windowproxy.go get global namespace packages together 7 years ago
worker.go have interfaces implement parent iface functions 7 years ago
workerglobalscope.go have interfaces implement parent iface functions 7 years ago
workerlocation.go Add support for interface constructor 7 years ago
workernavigator.go Add support for interface constructor 7 years ago
workertype.go get global namespace packages together 7 years ago
xmldocument.go have interfaces implement parent iface functions 7 years ago
xmlhttprequest.go have interfaces implement parent iface functions 7 years ago
xmlhttprequesteventtarget.go have interfaces implement parent iface functions 7 years ago
xmlhttprequestresponsetype.go get global namespace packages together 7 years ago
xmlhttprequestupload.go have interfaces implement parent iface functions 7 years ago
xmlserializer.go Add support for interface constructor 7 years ago

README.md

go-dom

This package is a work in progress

The go-dom package exposes the Web API Spec as a Go package.

This package is mostly just wrappers around calls to syscall/js to expose the browser Web API in a Go friendly manner.

This package's code is generated from WebIDL definitions for the various Web API Specs.

Examples

These examples can be compiled and run using GOARCH=wasm GOOS=js as described at https://github.com/golang/go/wiki/WebAssembly

Find all div elements and print them to the console

package main

import (
    "github.com/brettlangdon/go-dom/console"
    "github.com/brettlangdon/go-dom/document"
)

func main() {
    nodes := document.QuerySelectorAll("div")
    for i := 0; i < nodes.GetLength(); i++ {
        console.Dir(nodes.Item(0))
    }
}

Add a click handler to document which prints the event information.

package main

import (
    dom "github.com/brettlangdon/go-dom"
    "github.com/brettlangdon/go-dom/console"
    "github.com/brettlangdon/go-dom/document"
)

func main() {
    loop := dom.NewLoop()

    document.AddEventListener("click", dom.NewEventHandler(func(evt dom.Event) {
        console.Dir(evt)
    }))

    loop.Loop()
}

This last example uses a dom.Loop which is used to keep the program running instead of exiting.

If the Go program exits then the callback handlers will no longer execute.

Calling loop.Stop() will cause the Go program to exit.