How to use Validity method of html Package

Best K6 code snippet using html.Validity

form_impl.go

Source:form_impl.go Github

copy

Full Screen

...85}86func (p *htmlFormElementImpl) Reset() {87 p.call("reset")88}89func (p *htmlFormElementImpl) CheckValidity() bool {90 return p.call("checkValidity").toBool()91}92func (p *htmlFormElementImpl) ReportValidity() bool {93 return p.call("reportValidity").toBool()94}95// -------------8<---------------------------------------96type htmlFormControlsCollectionImpl struct {97 *htmlCollectionImpl98}99func wrapHTMLFormControlsCollection(v Value) HTMLFormControlsCollection {100 if v.valid() {101 return &htmlFormControlsCollectionImpl{102 htmlCollectionImpl: newHTMLCollectionImpl(v),103 }104 }105 return nil106}107//NOTE overriden namedbyItem108func (p *htmlFormControlsCollectionImpl) ItemByName(item string) HTMLFormControl {109 return wrapHTMLFormControl(p.call("namedItem", item))110}111// -------------8<---------------------------------------112type htmlFormControlImpl struct {113 Value114}115func wrapHTMLFormControl(v Value) HTMLFormControl {116 if v.valid() {117 return &htmlFormControlImpl{118 Value: v,119 }120 }121 return nil122}123// -------------8<---------------------------------------124type radioNodeListImpl struct {125 *nodeListImpl126}127func wrapRadioNodeList(v Value) RadioNodeList {128 if v.valid() {129 return &radioNodeListImpl{130 nodeListImpl: newNodeListImpl(v),131 }132 }133 return nil134}135func (p *radioNodeListImpl) Value() string {136 return p.get("value").toString()137}138func (p *radioNodeListImpl) SetValue(value string) {139 p.set("value", value)140}141// -------------8<---------------------------------------142type htmlLabelElementImpl struct {143 *htmlElementImpl144}145func NewHTMLLabelElement() HTMLLabelElement {146 if el := CurrentDocument().CreateElement("label"); el != nil {147 if label, ok := el.(HTMLLabelElement); ok {148 return label149 }150 }151 return nil152}153func wrapHTMLLabelElement(v Value) HTMLLabelElement {154 if v.valid() {155 return &htmlLabelElementImpl{156 htmlElementImpl: newHTMLElementImpl(v),157 }158 }159 return nil160}161func (p *htmlLabelElementImpl) Form() HTMLFormElement {162 return wrapHTMLFormElement(p.get("form"))163}164func (p *htmlLabelElementImpl) HtmlFor() string {165 return p.get("htmlFor").toString()166}167func (p *htmlLabelElementImpl) SetHtmlFor(hf string) {168 p.set("htmlFor", hf)169}170func (p *htmlLabelElementImpl) Control() HTMLElement {171 return wrapHTMLElement(p.get("control"))172}173// -------------8<---------------------------------------174type htmlInputElementImpl struct {175 *htmlElementImpl176}177var htmlInputElementTypeMap = map[string]string{178 "button": "button",179 "checkbox": "checkbox",180 "color": "color",181 "date": "date",182 "datetime-local": "datetime-local",183 "email": "email",184 "file": "file",185 "hidden": "hidden",186 "image": "image",187 "month": "month",188 "number": "number",189 "password": "password",190 "radio": "radio",191 "range": "range",192 "reset": "reset",193 "search": "search",194 "submit": "submit",195 "tel": "tel",196 "text": "text",197 "time": "time",198 "url": "url",199 "week": "week",200}201func NewHTMLInputElement(typ ...string) HTMLInputElement {202 if el := CurrentDocument().CreateElement("input"); el != nil {203 if input, ok := el.(HTMLInputElement); ok {204 if len(typ) > 0 {205 if t := htmlInputElementTypeMap[typ[0]]; t != "" {206 input.SetType(t)207 }208 }209 return input210 }211 }212 return nil213}214func wrapHTMLInputElement(v Value) HTMLInputElement {215 if v.valid() {216 return &htmlInputElementImpl{217 htmlElementImpl: newHTMLElementImpl(v),218 }219 }220 return nil221}222func (p *htmlInputElementImpl) Accept() string {223 return p.get("accept").toString()224}225func (p *htmlInputElementImpl) SetAccept(a string) {226 p.set("accept", a)227}228func (p *htmlInputElementImpl) Alt() string {229 return p.get("alt").toString()230}231func (p *htmlInputElementImpl) SetAlt(a string) {232 p.set("alt", a)233}234func (p *htmlInputElementImpl) Autocomplete() string {235 return p.get("autocomplete").toString()236}237func (p *htmlInputElementImpl) SetAutocomplete(ac string) {238 p.set("autocomplete", ac)239}240func (p *htmlInputElementImpl) Autofocus() bool {241 return p.get("autofocus").toBool()242}243func (p *htmlInputElementImpl) SetAutofocus(af bool) {244 p.set("autofocus", af)245}246func (p *htmlInputElementImpl) DefaultChecked() bool {247 return p.get("defaultChecked").toBool()248}249func (p *htmlInputElementImpl) SetDefaultChecked(dc bool) {250 p.set("defaultChecked", dc)251}252func (p *htmlInputElementImpl) Checked() bool {253 return p.get("checked").toBool()254}255func (p *htmlInputElementImpl) SetChecked(c bool) {256 p.set("checked", c)257}258func (p *htmlInputElementImpl) DirName() string {259 return p.get("dirName").toString()260}261func (p *htmlInputElementImpl) SetDirName(dn string) {262 p.set("dirName", dn)263}264func (p *htmlInputElementImpl) Disabled() bool {265 return p.get("disabled").toBool()266}267func (p *htmlInputElementImpl) SetDisabled(d bool) {268 p.set("disabled", d)269}270func (p *htmlInputElementImpl) Form() HTMLFormElement {271 return wrapHTMLFormElement(p.get("form"))272}273func (p *htmlInputElementImpl) Files() []File {274 return fileListToSlice(p.get("files"))275}276func (p *htmlInputElementImpl) FormAction() string {277 return p.get("formAction").toString()278}279func (p *htmlInputElementImpl) SetFormAction(fa string) {280 p.set("formAction", fa)281}282func (p *htmlInputElementImpl) FormEnctype() string {283 return p.get("formEnctype").toString()284}285func (p *htmlInputElementImpl) SetFormEnctype(fe string) {286 p.set("formEnctype", fe)287}288func (p *htmlInputElementImpl) FormMethod() string {289 return p.get("formMethod").toString()290}291func (p *htmlInputElementImpl) SetFormMethod(fm string) {292 p.set("formMethod", fm)293}294func (p *htmlInputElementImpl) FormNoValidate() bool {295 return p.get("formNoValidate").toBool()296}297func (p *htmlInputElementImpl) SetFormNoValidate(b bool) {298 p.set("formNoValidate", b)299}300func (p *htmlInputElementImpl) FormTarget() string {301 return p.get("formTarget").toString()302}303func (p *htmlInputElementImpl) SetFormTarget(ft string) {304 p.set("formTarget", ft)305}306func (p *htmlInputElementImpl) Height() uint {307 return p.get("height").toUint()308}309func (p *htmlInputElementImpl) SetHeight(h uint) {310 p.set("height", h)311}312func (p *htmlInputElementImpl) Indeterminate() bool {313 return p.get("indeterminate").toBool()314}315func (p *htmlInputElementImpl) SetIndeterminate(b bool) {316 p.set("indeterminate", b)317}318func (p *htmlInputElementImpl) List() HTMLElement {319 return wrapHTMLElement(p.get("list"))320}321func (p *htmlInputElementImpl) Max() string {322 return p.get("max").toString()323}324func (p *htmlInputElementImpl) SetMax(m string) {325 p.set("max", m)326}327func (p *htmlInputElementImpl) MaxLength() int {328 return p.get("maxLength").toInt()329}330func (p *htmlInputElementImpl) SetMaxLength(m int) {331 p.set("maxLength", m)332}333func (p *htmlInputElementImpl) Min() string {334 return p.get("min").toString()335}336func (p *htmlInputElementImpl) SetMin(m string) {337 p.set("min", m)338}339func (p *htmlInputElementImpl) MinLength() int {340 return p.get("minLength").toInt()341}342func (p *htmlInputElementImpl) SetMinLength(m int) {343 p.set("minLength", m)344}345func (p *htmlInputElementImpl) Multiple() bool {346 return p.get("multiple").toBool()347}348func (p *htmlInputElementImpl) SetMultiple(b bool) {349 p.set("multiple", b)350}351func (p *htmlInputElementImpl) Name() string {352 return p.get("name").toString()353}354func (p *htmlInputElementImpl) SetName(name string) {355 p.set("name", name)356}357func (p *htmlInputElementImpl) Pattern() string {358 return p.get("pattern").toString()359}360func (p *htmlInputElementImpl) SetPattern(pattern string) {361 p.set("pattern", pattern)362}363func (p *htmlInputElementImpl) Placeholder() string {364 return p.get("placeholder").toString()365}366func (p *htmlInputElementImpl) SetPlaceholder(ph string) {367 p.set("placeholder", ph)368}369func (p *htmlInputElementImpl) ReadOnly() bool {370 return p.get("readOnly").toBool()371}372func (p *htmlInputElementImpl) SetReadOnly(b bool) {373 p.set("readOnly", b)374}375func (p *htmlInputElementImpl) Required() bool {376 return p.get("_required").toBool()377}378func (p *htmlInputElementImpl) SetRequired(b bool) {379 p.set("_required", b)380}381func (p *htmlInputElementImpl) Size() uint {382 return p.get("size").toUint()383}384func (p *htmlInputElementImpl) SetSize(s uint) {385 p.set("size", s)386}387func (p *htmlInputElementImpl) Src() string {388 return p.get("src").toString()389}390func (p *htmlInputElementImpl) SetSrc(src string) {391 p.set("src", src)392}393func (p *htmlInputElementImpl) Step() string {394 return p.get("step").toString()395}396func (p *htmlInputElementImpl) SetStep(s string) {397 p.set("step", s)398}399func (p *htmlInputElementImpl) Type() string {400 return p.get("type").toString()401}402func (p *htmlInputElementImpl) SetType(t string) {403 p.set("type", t)404}405func (p *htmlInputElementImpl) DefaultValue() string {406 return p.get("defaultValue").toString()407}408func (p *htmlInputElementImpl) SetDefaultValue(dv string) {409 p.set("defaultValue", dv)410}411func (p *htmlInputElementImpl) Value() string {412 return p.get("value").toString()413}414func (p *htmlInputElementImpl) SetValue(value string) {415 p.set("value", value)416}417func (p *htmlInputElementImpl) ValueAsDate() time.Time {418 //TODO: test it419 return jsDateToTime(p.get("valueAsDate"))420}421func (p *htmlInputElementImpl) SetValueAsDate(t time.Time) {422 // TODO: test it423 d := jsDate.jsNew()424 d.call("setTime", t.Unix())425 p.set("valueAsDate", d)426}427func (p *htmlInputElementImpl) ValueAsNumber() float64 {428 return p.get("valueAsNumber").toFloat64()429}430func (p *htmlInputElementImpl) SetValueAsNumber(n float64) {431 p.set("valueAsNumber", n)432}433func (p *htmlInputElementImpl) Width() uint {434 return p.get("width").toUint()435}436func (p *htmlInputElementImpl) SetWidth(w uint) {437 p.set("width", w)438}439func (p *htmlInputElementImpl) StepUp(n ...int) {440 switch len(n) {441 case 0:442 p.call("stepUp")443 default:444 p.call("stepUp", n[0])445 }446}447func (p *htmlInputElementImpl) StepDown(n ...int) {448 switch len(n) {449 case 0:450 p.call("stepDown")451 default:452 p.call("stepDown", n[0])453 }454}455func (p *htmlInputElementImpl) WillValidate() bool {456 return p.get("willValidate").toBool()457}458func (p *htmlInputElementImpl) Validity() ValidityState {459 return wrapValidityState(p.get("validity"))460}461func (p *htmlInputElementImpl) ValidationMessage() string {462 return p.get("validationMessage").toString()463}464func (p *htmlInputElementImpl) CheckValidity() bool {465 return p.call("checkValidity").toBool()466}467func (p *htmlInputElementImpl) ReportValidity() bool {468 return p.call("reportValidity").toBool()469}470func (p *htmlInputElementImpl) SetCustomValidity(cv string) {471 p.call("setCustomValidity", cv)472}473func (p *htmlInputElementImpl) Labels() []Node {474 return nodeListToSlice(p.get("labels"))475}476func (p *htmlInputElementImpl) Select() {477 p.call("select")478}479func (p *htmlInputElementImpl) SelectionStart() uint {480 return p.get("selectionStart").toUint()481}482func (p *htmlInputElementImpl) SetSelectionStart(se uint) {483 p.set("selectionStart", se)484}485func (p *htmlInputElementImpl) SelectionEnd() uint {486 return p.get("selectionEnd").toUint()487}488func (p *htmlInputElementImpl) SetSelectionEnd(se uint) {489 p.set("selectionEnd", se)490}491func (p *htmlInputElementImpl) SelectionDirection() string {492 return p.get("selectionDirection").toString()493}494func (p *htmlInputElementImpl) SetSelectionDirection(sd string) {495 p.set("selectionDirection", sd)496}497func (p *htmlInputElementImpl) SetRangeText(r string, args ...interface{}) {498 switch len(args) {499 case 0:500 p.call("setRangeText", r)501 case 2:502 if start, ok := args[0].(uint); ok {503 if end, ok := args[1].(uint); ok {504 p.call("setRangeText", r, start, end)505 }506 }507 case 3:508 if start, ok := args[0].(uint); ok {509 if end, ok := args[1].(uint); ok {510 if selectionMode, ok := args[2].(SelectionMode); ok {511 p.call("setRangeText", r, start, end, string(selectionMode))512 }513 }514 }515 }516}517func (p *htmlInputElementImpl) SetSelectionRange(start uint, end uint, direction ...string) {518 switch len(direction) {519 case 0:520 p.call("setSelectionRange", start, end)521 default:522 p.call("setSelectionRange", start, end, direction[0])523 }524}525// -------------8<---------------------------------------526type htmlButtonElementImpl struct {527 *htmlElementImpl528}529func NewHTMLButtonElement() HTMLButtonElement {530 if el := CurrentDocument().CreateElement("button"); el != nil {531 if button, ok := el.(HTMLButtonElement); ok {532 return button533 }534 }535 return nil536}537func wrapHTMLButtonElement(v Value) HTMLButtonElement {538 if v.valid() {539 return &htmlButtonElementImpl{540 htmlElementImpl: newHTMLElementImpl(v),541 }542 }543 return nil544}545func (p *htmlButtonElementImpl) Autofocus() bool {546 return p.get("autofocus").toBool()547}548func (p *htmlButtonElementImpl) SetAutofocus(b bool) {549 p.set("autofocus", b)550}551func (p *htmlButtonElementImpl) Disabled() bool {552 return p.get("disabled").toBool()553}554func (p *htmlButtonElementImpl) SetDisabled(b bool) {555 p.set("disabled", b)556}557func (p *htmlButtonElementImpl) Form() HTMLFormElement {558 return wrapHTMLFormElement(p.get("form"))559}560func (p *htmlButtonElementImpl) FormAction() string {561 return p.get("formAction").toString()562}563func (p *htmlButtonElementImpl) SetFormAction(fa string) {564 p.set("formAction", fa)565}566func (p *htmlButtonElementImpl) FormEnctype() string {567 return p.get("formEnctype").toString()568}569func (p *htmlButtonElementImpl) SetFormEnctype(fe string) {570 p.set("formEnctype", fe)571}572func (p *htmlButtonElementImpl) FormMethod() string {573 return p.get("formMethod").toString()574}575func (p *htmlButtonElementImpl) SetFormMethod(fm string) {576 p.set("formMethod", fm)577}578func (p *htmlButtonElementImpl) FormNoValidate() bool {579 return p.get("formNoValidate").toBool()580}581func (p *htmlButtonElementImpl) SetFormNoValidate(b bool) {582 p.set("formNoValidate", b)583}584func (p *htmlButtonElementImpl) FormTarget() string {585 return p.get("formTarget").toString()586}587func (p *htmlButtonElementImpl) SetFormTarget(ft string) {588 p.set("formTarget", ft)589}590func (p *htmlButtonElementImpl) Name() string {591 return p.get("name").toString()592}593func (p *htmlButtonElementImpl) SetName(name string) {594 p.set("name", name)595}596func (p *htmlButtonElementImpl) Type() string {597 return p.get("type").toString()598}599func (p *htmlButtonElementImpl) SetType(t string) {600 p.set("type", t)601}602func (p *htmlButtonElementImpl) Value() string {603 return p.get("value").toString()604}605func (p *htmlButtonElementImpl) SetValue(v string) {606 p.set("value", v)607}608func (p *htmlButtonElementImpl) WillValidate() bool {609 return p.get("willValidate").toBool()610}611func (p *htmlButtonElementImpl) Validity() ValidityState {612 return wrapValidityState(p.get("validity"))613}614func (p *htmlButtonElementImpl) ValidationMessage() string {615 return p.get("validationMessage").toString()616}617func (p *htmlButtonElementImpl) CheckValidity() bool {618 return p.call("checkValidity").toBool()619}620func (p *htmlButtonElementImpl) ReportValidity() bool {621 return p.call("reportValidity").toBool()622}623func (p *htmlButtonElementImpl) SetCustomValidity(e string) {624 p.call("setCustomValidity", e)625}626func (p *htmlButtonElementImpl) Labels() []Node {627 return nodeListToSlice(p.get("labels"))628}629// -------------8<---------------------------------------630type htmlSelectElementImpl struct {631 *htmlElementImpl632}633func NewHTMLSelectElement() HTMLSelectElement {634 if el := CurrentDocument().CreateElement("select"); el != nil {635 if sel, ok := el.(HTMLSelectElement); ok {636 return sel637 }638 }639 return nil640}641func wrapHTMLSelectElement(v Value) HTMLSelectElement {642 if v.valid() {643 return &htmlSelectElementImpl{644 htmlElementImpl: newHTMLElementImpl(v),645 }646 }647 return nil648}649func (p *htmlSelectElementImpl) Autocomplete() string {650 return p.get("autocomplete").toString()651}652func (p *htmlSelectElementImpl) SetAutocomplete(ac string) {653 p.set("autocomplete", ac)654}655func (p *htmlSelectElementImpl) Autofocus() bool {656 return p.get("autofocus").toBool()657}658func (p *htmlSelectElementImpl) SetAutofocus(af bool) {659 p.set("autofocus", af)660}661func (p *htmlSelectElementImpl) Disabled() bool {662 return p.get("disabled").toBool()663}664func (p *htmlSelectElementImpl) SetDisabled(b bool) {665 p.set("disabled", b)666}667func (p *htmlSelectElementImpl) Form() HTMLFormElement {668 return wrapHTMLFormElement(p.get("form"))669}670func (p *htmlSelectElementImpl) Multiple() bool {671 return p.get("multiple").toBool()672}673func (p *htmlSelectElementImpl) SetMultiple(m bool) {674 p.set("multiple", m)675}676func (p *htmlSelectElementImpl) Name() string {677 return p.get("name").toString()678}679func (p *htmlSelectElementImpl) SetName(name string) {680 p.set("name", name)681}682func (p *htmlSelectElementImpl) Required() bool {683 return p.get("_required").toBool()684}685func (p *htmlSelectElementImpl) SetRequired(b bool) {686 p.set("_required", b)687}688func (p *htmlSelectElementImpl) Size() uint {689 return p.get("size").toUint()690}691func (p *htmlSelectElementImpl) SetSize(s uint) {692 p.set("size", s)693}694func (p *htmlSelectElementImpl) Type() string {695 return p.get("type").toString()696}697func (p *htmlSelectElementImpl) Options() HTMLOptionsCollection {698 return wrapHTMLOptionsCollection(p.get("options"))699}700func (p *htmlSelectElementImpl) Length() uint {701 return p.get("length").toUint()702}703func (p *htmlSelectElementImpl) SetLength(l uint) {704 p.set("length", l)705}706func (p *htmlSelectElementImpl) Item(index uint) Element {707 return wrapAsElement(p.call("item", index))708}709func (p *htmlSelectElementImpl) NamedItem(name string) HTMLOptionElement {710 return wrapHTMLOptionElement(p.call("namedItem", name))711}712func (p *htmlSelectElementImpl) Add(element HTMLElement, before ...interface{}) {713 switch len(before) {714 case 0:715 p.call("add", JSValueOf(element))716 default:717 switch x := before[0].(type) {718 case HTMLElement:719 p.call("add", JSValueOf(element), JSValueOf(x))720 case int:721 p.call("add", JSValueOf(element), x)722 }723 }724}725func (p *htmlSelectElementImpl) RemoveByIndex(index int) {726 p.call("remove", index)727}728func (p *htmlSelectElementImpl) Set(index uint, option HTMLOptionElement) {729 // TODO730 // which method ??731 // setter void (unsigned long index, HTMLOptionElement? option);732}733func (p *htmlSelectElementImpl) SelectedOptions() []HTMLOptionElement {734 return htmlCollectionToHTMLOptionElementSlice(p.get("selectedOptions"))735}736func (p *htmlSelectElementImpl) SelectedIndex() int {737 return p.get("selectedIndex").toInt()738}739func (p *htmlSelectElementImpl) SetSelectedIndex(index int) {740 p.set("selectedIndex", index)741}742func (p *htmlSelectElementImpl) Value() string {743 return p.get("value").toString()744}745func (p *htmlSelectElementImpl) SetValue(v string) {746 p.set("value", v)747}748func (p *htmlSelectElementImpl) WillValidate() bool {749 return p.get("willValidate").toBool()750}751func (p *htmlSelectElementImpl) Validity() ValidityState {752 return wrapValidityState(p.get("validity"))753}754func (p *htmlSelectElementImpl) ValidationMessage() string {755 return p.get("validationMessage").toString()756}757func (p *htmlSelectElementImpl) CheckValidity() bool {758 return p.call("checkValidity").toBool()759}760func (p *htmlSelectElementImpl) ReportValidity() bool {761 return p.call("reportValidity").toBool()762}763func (p *htmlSelectElementImpl) SetCustomValidity(e string) {764 p.call("setCustomValidity", e)765}766func (p *htmlSelectElementImpl) Labels() []Node {767 return nodeListToSlice(p.get("labels"))768}769// -------------8<---------------------------------------770type htmlOptionsCollectionImpl struct {771 *htmlCollectionImpl772}773func wrapHTMLOptionsCollection(v Value) HTMLOptionsCollection {774 if v.valid() {775 return &htmlOptionsCollectionImpl{776 htmlCollectionImpl: newHTMLCollectionImpl(v),777 }778 }779 return nil780}781func (p *htmlOptionsCollectionImpl) Length() uint {782 return p.get("length").toUint()783}784/* TODO setter785func (p *htmlOptionsCollectionImpl) Set(index uint,option HTMLOptionElement) {786 p.call("")787}788*/789func (p *htmlOptionsCollectionImpl) Add(element HTMLElement, before ...interface{}) {790 switch len(before) {791 case 0:792 p.call("add", JSValueOf(element))793 default:794 switch x := before[0].(type) {795 case HTMLElement:796 p.call("add", JSValueOf(element), JSValueOf(x))797 case int:798 p.call("add", JSValueOf(element), x)799 }800 }801}802func (p *htmlOptionsCollectionImpl) Remove(index int) {803 p.call("remove", index)804}805func (p *htmlOptionsCollectionImpl) SelectedIndex() int {806 return p.get("selectedIndex").toInt()807}808func (p *htmlOptionsCollectionImpl) SetSelectedIndex(i int) {809 p.set("selectedIndex", i)810}811// -------------8<---------------------------------------812type htmlDataListElementImpl struct {813 *htmlElementImpl814}815func NewHTMLDataListElement() HTMLDataListElement {816 if el := CurrentDocument().CreateElement("datalist"); el != nil {817 if datalist, ok := el.(HTMLDataListElement); ok {818 return datalist819 }820 }821 return nil822}823func wrapHTMLDataListElement(v Value) HTMLDataListElement {824 if v.valid() {825 return &htmlDataListElementImpl{826 htmlElementImpl: newHTMLElementImpl(v),827 }828 }829 return nil830}831func (p *htmlDataListElementImpl) Options() []HTMLOptionElement {832 return htmlCollectionToHTMLOptionElementSlice(p.get("options"))833}834// -------------8<---------------------------------------835type htmlOptGroupElementImpl struct {836 *htmlElementImpl837}838func NewHTMLOptGroupElement() HTMLOptGroupElement {839 if el := CurrentDocument().CreateElement("optgroup"); el != nil {840 if optgroup, ok := el.(HTMLOptGroupElement); ok {841 return optgroup842 }843 }844 return nil845}846func wrapHTMLOptGroupElement(v Value) HTMLOptGroupElement {847 if v.valid() {848 return &htmlOptGroupElementImpl{849 htmlElementImpl: newHTMLElementImpl(v),850 }851 }852 return nil853}854func (p *htmlOptGroupElementImpl) Disabled() bool {855 return p.get("disabled").toBool()856}857func (p *htmlOptGroupElementImpl) SetDisabled(b bool) {858 p.set("disabled", b)859}860func (p *htmlOptGroupElementImpl) Label() string {861 return p.get("label").toString()862}863func (p *htmlOptGroupElementImpl) SetLabel(lbl string) {864 p.set("label", lbl)865}866// -------------8<---------------------------------------867type htmlOptionElementImpl struct {868 *htmlElementImpl869}870/*871func NewHTMLOptionElement() HTMLOptionElement {872 if el := CurrentDocument().CreateElement("option"); el != nil {873 if option, ok := el.(HTMLOptionElement); ok {874 return option875 }876 }877 return nil878}879*/880//Named Constructor881func NewOption(args ...interface{}) HTMLOptionElement {882 if jsOpt := jsGlobal.get("Option"); jsOpt.valid() {883 switch len(args) {884 case 1:885 if text, ok := args[0].(string); ok {886 return wrapHTMLOptionElement(jsOpt.jsNew(text))887 }888 case 2:889 if text, ok := args[0].(string); ok {890 if value, ok := args[1].(string); ok {891 return wrapHTMLOptionElement(jsOpt.jsNew(text, value))892 }893 }894 case 3:895 if text, ok := args[0].(string); ok {896 if value, ok := args[1].(string); ok {897 if defaultSelected, ok := args[2].(bool); ok {898 return wrapHTMLOptionElement(jsOpt.jsNew(text, value, defaultSelected))899 }900 }901 }902 case 4:903 if text, ok := args[0].(string); ok {904 if value, ok := args[1].(string); ok {905 if defaultSelected, ok := args[2].(bool); ok {906 if selected, ok := args[3].(bool); ok {907 return wrapHTMLOptionElement(jsOpt.jsNew(text, value, defaultSelected, selected))908 }909 }910 }911 }912 }913 return wrapHTMLOptionElement(jsOpt.jsNew())914 }915 return nil916}917func wrapHTMLOptionElement(v Value) HTMLOptionElement {918 if v.valid() {919 return &htmlOptionElementImpl{920 htmlElementImpl: newHTMLElementImpl(v),921 }922 }923 return nil924}925func (p *htmlOptionElementImpl) Disabled() bool {926 return p.get("disabled").toBool()927}928func (p *htmlOptionElementImpl) SetDisabled(b bool) {929 p.set("disabled", b)930}931func (p *htmlOptionElementImpl) Form() HTMLFormElement {932 return wrapHTMLFormElement(p.get("form"))933}934func (p *htmlOptionElementImpl) Label() string {935 return p.get("label").toString()936}937func (p *htmlOptionElementImpl) SetLabel(lbl string) {938 p.set("label", lbl)939}940func (p *htmlOptionElementImpl) DefaultSelected() bool {941 return p.get("defaultSelected").toBool()942}943func (p *htmlOptionElementImpl) SetDefaultSelected(b bool) {944 p.set("defaultSelected", b)945}946func (p *htmlOptionElementImpl) Selected() bool {947 return p.get("selected").toBool()948}949func (p *htmlOptionElementImpl) SetSelected(b bool) {950 p.set("selected", b)951}952func (p *htmlOptionElementImpl) Value() string {953 return p.get("value").toString()954}955func (p *htmlOptionElementImpl) SetValue(v string) {956 p.set("value", v)957}958func (p *htmlOptionElementImpl) Text() string {959 return p.get("text").toString()960}961func (p *htmlOptionElementImpl) SetText(t string) {962 p.set("text", t)963}964func (p *htmlOptionElementImpl) Index() int {965 return p.get("index").toInt()966}967// -------------8<---------------------------------------968type htmlTextAreaElementImpl struct {969 *htmlElementImpl970}971func NewHTMLTextAreaElement() HTMLTextAreaElement {972 if el := CurrentDocument().CreateElement("textarea"); el != nil {973 if textarea, ok := el.(HTMLTextAreaElement); ok {974 return textarea975 }976 }977 return nil978}979func wrapHTMLTextAreaElement(v Value) HTMLTextAreaElement {980 if v.valid() {981 return &htmlTextAreaElementImpl{982 htmlElementImpl: newHTMLElementImpl(v),983 }984 }985 return nil986}987func (p *htmlTextAreaElementImpl) Autocomplete() string {988 return p.get("autocomplete").toString()989}990func (p *htmlTextAreaElementImpl) SetAutocomplete(ac string) {991 p.set("autocomplete", ac)992}993func (p *htmlTextAreaElementImpl) Autofocus() bool {994 return p.get("autofocus").toBool()995}996func (p *htmlTextAreaElementImpl) SetAutofocus(b bool) {997 p.set("autofocus", b)998}999func (p *htmlTextAreaElementImpl) Cols() uint {1000 return p.get("cols").toUint()1001}1002func (p *htmlTextAreaElementImpl) SetCols(c uint) {1003 p.set("cols", c)1004}1005func (p *htmlTextAreaElementImpl) DirName() string {1006 return p.get("dirName").toString()1007}1008func (p *htmlTextAreaElementImpl) SetDirName(dn string) {1009 p.set("dirName", dn)1010}1011func (p *htmlTextAreaElementImpl) Disabled() bool {1012 return p.get("disabled").toBool()1013}1014func (p *htmlTextAreaElementImpl) SetDisabled(b bool) {1015 p.set("disabled", b)1016}1017func (p *htmlTextAreaElementImpl) Form() HTMLFormElement {1018 return wrapHTMLFormElement(p.get("form"))1019}1020func (p *htmlTextAreaElementImpl) MaxLength() int {1021 return p.get("maxLength").toInt()1022}1023func (p *htmlTextAreaElementImpl) SetMaxLength(m int) {1024 p.set("maxLength", m)1025}1026func (p *htmlTextAreaElementImpl) MinLength() int {1027 return p.get("minLength").toInt()1028}1029func (p *htmlTextAreaElementImpl) SetMinLength(m int) {1030 p.set("minLength", m)1031}1032func (p *htmlTextAreaElementImpl) Name() string {1033 return p.get("name").toString()1034}1035func (p *htmlTextAreaElementImpl) SetName(name string) {1036 p.set("name", name)1037}1038func (p *htmlTextAreaElementImpl) Placeholder() string {1039 return p.get("placeholder").toString()1040}1041func (p *htmlTextAreaElementImpl) SetPlaceholder(h string) {1042 p.set("placeholder", h)1043}1044func (p *htmlTextAreaElementImpl) ReadOnly() bool {1045 return p.get("readOnly").toBool()1046}1047func (p *htmlTextAreaElementImpl) SetReadOnly(b bool) {1048 p.set("readOnly", b)1049}1050func (p *htmlTextAreaElementImpl) Required() bool {1051 return p.get("_required").toBool()1052}1053func (p *htmlTextAreaElementImpl) SetRequired(b bool) {1054 p.set("_required", b)1055}1056func (p *htmlTextAreaElementImpl) Rows() uint {1057 return p.get("rows").toUint()1058}1059func (p *htmlTextAreaElementImpl) SetRows(r uint) {1060 p.set("rows", r)1061}1062func (p *htmlTextAreaElementImpl) Wrap() string {1063 return p.get("wrap").toString()1064}1065func (p *htmlTextAreaElementImpl) SetWrap(w string) {1066 p.set("wrap", w)1067}1068func (p *htmlTextAreaElementImpl) Type() string {1069 return p.get("type").toString()1070}1071func (p *htmlTextAreaElementImpl) DefaultValue() string {1072 return p.get("defaultValue").toString()1073}1074func (p *htmlTextAreaElementImpl) SetDefaultValue(dv string) {1075 p.set("defaultValue", dv)1076}1077func (p *htmlTextAreaElementImpl) Value() string {1078 return p.get("value").toString()1079}1080func (p *htmlTextAreaElementImpl) SetValue(v string) {1081 p.set("value", v)1082}1083func (p *htmlTextAreaElementImpl) TextLength() uint {1084 return p.get("textLength").toUint()1085}1086func (p *htmlTextAreaElementImpl) WillValidate() bool {1087 return p.get("willValidate").toBool()1088}1089func (p *htmlTextAreaElementImpl) Validity() ValidityState {1090 return wrapValidityState(p.get("validity"))1091}1092func (p *htmlTextAreaElementImpl) ValidationMessage() string {1093 return p.get("validationMessage").toString()1094}1095func (p *htmlTextAreaElementImpl) CheckValidity() bool {1096 return p.call("checkValidity").toBool()1097}1098func (p *htmlTextAreaElementImpl) ReportValidity() bool {1099 return p.call("reportValidity").toBool()1100}1101func (p *htmlTextAreaElementImpl) SetCustomValidity(e string) {1102 p.call("setCustomValidity", e)1103}1104func (p *htmlTextAreaElementImpl) Labels() []Node {1105 return nodeListToSlice(p.get("labels"))1106}1107func (p *htmlTextAreaElementImpl) Select() {1108 p.call("select")1109}1110func (p *htmlTextAreaElementImpl) SelectionStart() uint {1111 return p.get("selectionStart").toUint()1112}1113func (p *htmlTextAreaElementImpl) SetSelectionStart(ss uint) {1114 p.set("selectionStart", ss)1115}1116func (p *htmlTextAreaElementImpl) SelectionEnd() uint {1117 return p.get("selectionEnd").toUint()1118}1119func (p *htmlTextAreaElementImpl) SetSelectionEnd(se uint) {1120 p.set("selectionEnd", se)1121}1122func (p *htmlTextAreaElementImpl) SelectionDirection() string {1123 return p.get("selectionDirection").toString()1124}1125func (p *htmlTextAreaElementImpl) SetSelectionDirection(sd string) {1126 p.set("selectionDirection", sd)1127}1128func (p *htmlTextAreaElementImpl) SetRangeText(r string, args ...interface{}) {1129 switch len(args) {1130 case 0:1131 p.call("setRangeText", r)1132 case 2:1133 if start, ok := args[0].(uint); ok {1134 if end, ok := args[1].(uint); ok {1135 p.call("setRangeText", r, start, end)1136 }1137 }1138 case 3:1139 if start, ok := args[0].(uint); ok {1140 if end, ok := args[1].(uint); ok {1141 if selectionMode, ok := args[2].(SelectionMode); ok {1142 p.call("setRangeText", r, start, end, string(selectionMode))1143 }1144 }1145 }1146 }1147}1148func (p *htmlTextAreaElementImpl) SetSelectionRange(start uint, end uint, direction ...string) {1149 switch len(direction) {1150 case 0:1151 p.call("setSelectionRange", start, end)1152 default:1153 p.call("setSelectionRange", start, end, direction[0])1154 }1155}1156// -------------8<---------------------------------------1157type htmlOutputElementImpl struct {1158 *htmlElementImpl1159}1160func NewHTMLOutputElement() HTMLOutputElement {1161 if el := CurrentDocument().CreateElement("output"); el != nil {1162 if output, ok := el.(HTMLOutputElement); ok {1163 return output1164 }1165 }1166 return nil1167}1168func wrapHTMLOutputElement(v Value) HTMLOutputElement {1169 if v.valid() {1170 return &htmlOutputElementImpl{1171 htmlElementImpl: newHTMLElementImpl(v),1172 }1173 }1174 return nil1175}1176func (p *htmlOutputElementImpl) HtmlFor() DOMTokenList {1177 return wrapDOMTokenList(p.get("htmlFor"))1178}1179func (p *htmlOutputElementImpl) Form() HTMLFormElement {1180 return wrapHTMLFormElement(p.get("form"))1181}1182func (p *htmlOutputElementImpl) Name() string {1183 return p.get("name").toString()1184}1185func (p *htmlOutputElementImpl) SetName(name string) {1186 p.set("name", name)1187}1188func (p *htmlOutputElementImpl) Type() string {1189 return p.get("type").toString()1190}1191func (p *htmlOutputElementImpl) DefaultValue() string {1192 return p.get("defaultValue").toString()1193}1194func (p *htmlOutputElementImpl) SetDefaultValue(dv string) {1195 p.set("defaultValue", dv)1196}1197func (p *htmlOutputElementImpl) Value() string {1198 return p.get("value").toString()1199}1200func (p *htmlOutputElementImpl) SetValue(v string) {1201 p.set("value", v)1202}1203func (p *htmlOutputElementImpl) WillValidate() bool {1204 return p.get("willValidate").toBool()1205}1206func (p *htmlOutputElementImpl) Validity() ValidityState {1207 return wrapValidityState(p.get("validity"))1208}1209func (p *htmlOutputElementImpl) ValidationMessage() string {1210 return p.get("validationMessage").toString()1211}1212func (p *htmlOutputElementImpl) CheckValidity() bool {1213 return p.call("checkValidity").toBool()1214}1215func (p *htmlOutputElementImpl) ReportValidity() bool {1216 return p.call("reportValidity").toBool()1217}1218func (p *htmlOutputElementImpl) SetCustomValidity(e string) {1219 p.call("setCustomValidity", e)1220}1221func (p *htmlOutputElementImpl) Labels() []Node {1222 return nodeListToSlice(p.get("labels"))1223}1224// -------------8<---------------------------------------1225type htmlProgressElementImpl struct {1226 *htmlElementImpl1227}1228func NewHTMLProgressElement() HTMLProgressElement {1229 if el := CurrentDocument().CreateElement("progress"); el != nil {1230 if progress, ok := el.(HTMLProgressElement); ok {1231 return progress1232 }1233 }1234 return nil1235}1236func wrapHTMLProgressElement(v Value) HTMLProgressElement {1237 if v.valid() {1238 return &htmlProgressElementImpl{1239 htmlElementImpl: newHTMLElementImpl(v),1240 }1241 }1242 return nil1243}1244func (p *htmlProgressElementImpl) Value() float64 {1245 return p.get("value").toFloat64()1246}1247func (p *htmlProgressElementImpl) SetValue(v float64) {1248 p.set("value", v)1249}1250func (p *htmlProgressElementImpl) Max() float64 {1251 return p.get("max").toFloat64()1252}1253func (p *htmlProgressElementImpl) SetMax(m float64) {1254 p.set("max", m)1255}1256func (p *htmlProgressElementImpl) Position() float64 {1257 return p.get("position").toFloat64()1258}1259func (p *htmlProgressElementImpl) Labels() []Node {1260 return nodeListToSlice(p.get("labels"))1261}1262// -------------8<---------------------------------------1263type htmlMeterElementImpl struct {1264 *htmlElementImpl1265}1266func NewHTMLMeterElement() HTMLMeterElement {1267 if el := CurrentDocument().CreateElement("meter"); el != nil {1268 if meter, ok := el.(HTMLMeterElement); ok {1269 return meter1270 }1271 }1272 return nil1273}1274func wrapHTMLMeterElement(v Value) HTMLMeterElement {1275 if v.valid() {1276 return &htmlMeterElementImpl{1277 htmlElementImpl: newHTMLElementImpl(v),1278 }1279 }1280 return nil1281}1282func (p *htmlMeterElementImpl) Value() float64 {1283 return p.get("value").toFloat64()1284}1285func (p *htmlMeterElementImpl) SetValue(v float64) {1286 p.set("value", v)1287}1288func (p *htmlMeterElementImpl) Min() float64 {1289 return p.get("min").toFloat64()1290}1291func (p *htmlMeterElementImpl) SetMin(m float64) {1292 p.set("min", m)1293}1294func (p *htmlMeterElementImpl) Max() float64 {1295 return p.get("max").toFloat64()1296}1297func (p *htmlMeterElementImpl) SetMax(m float64) {1298 p.set("max", m)1299}1300func (p *htmlMeterElementImpl) Low() float64 {1301 return p.get("low").toFloat64()1302}1303func (p *htmlMeterElementImpl) SetLow(v float64) {1304 p.set("low", v)1305}1306func (p *htmlMeterElementImpl) High() float64 {1307 return p.get("high").toFloat64()1308}1309func (p *htmlMeterElementImpl) SetHigh(v float64) {1310 p.set("high", v)1311}1312func (p *htmlMeterElementImpl) Optimum() float64 {1313 return p.get("optimum").toFloat64()1314}1315func (p *htmlMeterElementImpl) SetOptimum(v float64) {1316 p.set("optimum", v)1317}1318func (p *htmlMeterElementImpl) Labels() []Node {1319 return nodeListToSlice(p.get("labels"))1320}1321// -------------8<---------------------------------------1322type htmlFieldSetElementImpl struct {1323 *htmlElementImpl1324}1325func NewHTMLFieldSetElement() HTMLFieldSetElement {1326 if el := CurrentDocument().CreateElement("fieldset"); el != nil {1327 if fieldset, ok := el.(HTMLFieldSetElement); ok {1328 return fieldset1329 }1330 }1331 return nil1332}1333func wrapHTMLFieldSetElement(v Value) HTMLFieldSetElement {1334 if v.valid() {1335 return &htmlFieldSetElementImpl{1336 htmlElementImpl: newHTMLElementImpl(v),1337 }1338 }1339 return nil1340}1341func (p *htmlFieldSetElementImpl) Disabled() bool {1342 return p.get("disabled").toBool()1343}1344func (p *htmlFieldSetElementImpl) SetDisabled(b bool) {1345 p.set("disabled", b)1346}1347func (p *htmlFieldSetElementImpl) Form() HTMLFormElement {1348 return wrapHTMLFormElement(p.get("form"))1349}1350func (p *htmlFieldSetElementImpl) Name() string {1351 return p.get("name").toString()1352}1353func (p *htmlFieldSetElementImpl) SetName(name string) {1354 p.set("name", name)1355}1356func (p *htmlFieldSetElementImpl) Type() string {1357 return p.get("type").toString()1358}1359func (p *htmlFieldSetElementImpl) Elements() []HTMLElement {1360 return htmlCollectionToHTMLElementSlice(p.get("elements"))1361}1362func (p *htmlFieldSetElementImpl) WillValidate() bool {1363 return p.get("willValidate").toBool()1364}1365func (p *htmlFieldSetElementImpl) Validity() ValidityState {1366 return wrapValidityState(p.get("validity"))1367}1368func (p *htmlFieldSetElementImpl) ValidationMessage() string {1369 return p.get("validationMessage").toString()1370}1371func (p *htmlFieldSetElementImpl) CheckValidity() bool {1372 return p.call("checkValidity").toBool()1373}1374func (p *htmlFieldSetElementImpl) ReportValidity() bool {1375 return p.call("reportValidity").toBool()1376}1377func (p *htmlFieldSetElementImpl) SetCustomValidity(e string) {1378 p.call("setCustomValidity", e)1379}1380// -------------8<---------------------------------------1381type htmlLegendElementImpl struct {1382 *htmlElementImpl1383}1384func NewHTMLLegendElement() HTMLLegendElement {1385 if el := CurrentDocument().CreateElement("legend"); el != nil {1386 if legend, ok := el.(HTMLLegendElement); ok {1387 return legend1388 }1389 }1390 return nil1391}1392func wrapHTMLLegendElement(v Value) HTMLLegendElement {...

Full Screen

Full Screen

form.go

Source:form.go Github

copy

Full Screen

...27 SetTarget(string)28 Elements() HTMLFormControlsCollection29 Submit()30 Reset()31 CheckValidity() bool32 ReportValidity() bool33 }34 // https://www.w3.org/TR/html52/infrastructure.html#htmlformcontrolscollection35 HTMLFormControlsCollection interface {36 HTMLCollection37 ItemByName(string) HTMLFormControl38 }39 // Element or RadioNodeList40 HTMLFormControl interface{}41 // https://www.w3.org/TR/html52/infrastructure.html#radionodelist42 RadioNodeList interface {43 NodeList44 Value() string45 SetValue(string)46 }47 // https://www.w3.org/TR/html52/sec-forms.html#htmllabelelement48 HTMLLabelElement interface {49 HTMLElement50 Form() HTMLFormElement51 HtmlFor() string52 SetHtmlFor(string)53 Control() HTMLElement54 }55 // https://www.w3.org/TR/html52/sec-forms.html#htmlinputelement56 HTMLInputElement interface {57 HTMLElement58 Accept() string59 SetAccept(string)60 Alt() string61 SetAlt(string)62 Autocomplete() string63 SetAutocomplete(string)64 Autofocus() bool65 SetAutofocus(bool)66 DefaultChecked() bool67 SetDefaultChecked(bool)68 Checked() bool69 SetChecked(bool)70 DirName() string71 SetDirName(string)72 Disabled() bool73 SetDisabled(bool)74 Form() HTMLFormElement75 Files() []File76 FormAction() string77 SetFormAction(string)78 FormEnctype() string79 SetFormEnctype(string)80 FormMethod() string81 SetFormMethod(string)82 FormNoValidate() bool83 SetFormNoValidate(bool)84 FormTarget() string85 SetFormTarget(string)86 Height() uint87 SetHeight(uint)88 Indeterminate() bool89 SetIndeterminate(bool)90 List() HTMLElement91 Max() string92 SetMax(string)93 MaxLength() int94 SetMaxLength(int)95 Min() string96 SetMin(string)97 MinLength() int98 SetMinLength(int)99 Multiple() bool100 SetMultiple(bool)101 Name() string102 SetName(string)103 Pattern() string104 SetPattern(string)105 Placeholder() string106 SetPlaceholder(string)107 ReadOnly() bool108 SetReadOnly(bool)109 Required() bool110 SetRequired(bool)111 Size() uint112 SetSize(uint)113 Src() string114 SetSrc(string)115 Step() string116 SetStep(string)117 Type() string118 SetType(string)119 DefaultValue() string120 SetDefaultValue(string)121 Value() string122 SetValue(string)123 ValueAsDate() time.Time124 SetValueAsDate(time.Time)125 ValueAsNumber() float64126 SetValueAsNumber(float64)127 Width() uint128 SetWidth(uint)129 StepUp(...int)130 StepDown(...int)131 WillValidate() bool132 Validity() ValidityState133 ValidationMessage() string134 CheckValidity() bool135 ReportValidity() bool136 SetCustomValidity(string)137 Labels() []Node138 Select()139 SelectionStart() uint140 SetSelectionStart(uint)141 SelectionEnd() uint142 SetSelectionEnd(uint)143 SelectionDirection() string144 SetSelectionDirection(string)145 SetRangeText(string, ...interface{})146 SetSelectionRange(uint, uint, ...string)147 }148 // https://www.w3.org/TR/html52/sec-forms.html#htmlbuttonelement149 HTMLButtonElement interface {150 HTMLElement151 Autofocus() bool152 SetAutofocus(bool)153 Disabled() bool154 SetDisabled(bool)155 Form() HTMLFormElement156 FormAction() string157 SetFormAction(string)158 FormEnctype() string159 SetFormEnctype(string)160 FormMethod() string161 SetFormMethod(string)162 FormNoValidate() bool163 SetFormNoValidate(bool)164 FormTarget() string165 SetFormTarget(string)166 Name() string167 SetName(string)168 Type() string169 SetType(string)170 Value() string171 SetValue(string)172 WillValidate() bool173 Validity() ValidityState174 ValidationMessage() string175 CheckValidity() bool176 ReportValidity() bool177 SetCustomValidity(string)178 Labels() []Node179 }180 // https://www.w3.org/TR/html52/sec-forms.html#htmlselectelement181 HTMLSelectElement interface {182 HTMLElement183 Autocomplete() string184 SetAutocomplete(string)185 Autofocus() bool186 SetAutofocus(bool)187 Disabled() bool188 SetDisabled(bool)189 Form() HTMLFormElement190 Multiple() bool191 SetMultiple(bool)192 Name() string193 SetName(string)194 Required() bool195 SetRequired(bool)196 Size() uint197 SetSize(uint)198 Type() string199 Options() HTMLOptionsCollection200 Length() uint201 SetLength(uint)202 Item(uint) Element203 NamedItem(string) HTMLOptionElement204 Add(HTMLElement, ...interface{})205 RemoveByIndex(int)206 Set(uint, HTMLOptionElement)207 SelectedOptions() []HTMLOptionElement208 SelectedIndex() int209 SetSelectedIndex(int)210 Value() string211 SetValue(string)212 WillValidate() bool213 Validity() ValidityState214 ValidationMessage() string215 CheckValidity() bool216 ReportValidity() bool217 SetCustomValidity(string)218 Labels() []Node219 }220 // https://www.w3.org/TR/html52/infrastructure.html#htmloptionscollection221 HTMLOptionsCollection interface {222 HTMLCollection223 //Set(uint, HTMLOptionElement)224 Add(HTMLElement, ...interface{})225 Remove(int)226 SelectedIndex() int227 SetSelectedIndex(int)228 }229 // https://www.w3.org/TR/html52/sec-forms.html#htmldatalistelement230 HTMLDataListElement interface {231 HTMLElement232 Options() []HTMLOptionElement233 }234 // https://www.w3.org/TR/html52/sec-forms.html#htmloptgroupelement235 HTMLOptGroupElement interface {236 HTMLElement237 Disabled() bool238 SetDisabled(bool)239 Label() string240 SetLabel(string)241 }242 // https://www.w3.org/TR/html52/sec-forms.html#htmloptionelement243 HTMLOptionElement interface {244 HTMLElement245 Disabled() bool246 SetDisabled(bool)247 Form() HTMLFormElement248 Label() string249 SetLabel(string)250 DefaultSelected() bool251 SetDefaultSelected(bool)252 Selected() bool253 SetSelected(bool)254 Value() string255 SetValue(string)256 Text() string257 SetText(string)258 Index() int259 }260 // https://www.w3.org/TR/html52/sec-forms.html#htmltextareaelement261 HTMLTextAreaElement interface {262 HTMLElement263 Autocomplete() string264 SetAutocomplete(string)265 Autofocus() bool266 SetAutofocus(bool)267 Cols() uint268 SetCols(uint)269 DirName() string270 SetDirName(string)271 Disabled() bool272 SetDisabled(bool)273 Form() HTMLFormElement274 MaxLength() int275 SetMaxLength(int)276 MinLength() int277 SetMinLength(int)278 Name() string279 SetName(string)280 Placeholder() string281 SetPlaceholder(string)282 ReadOnly() bool283 SetReadOnly(bool)284 Required() bool285 SetRequired(bool)286 Rows() uint287 SetRows(uint)288 Wrap() string289 SetWrap(string)290 Type() string291 DefaultValue() string292 SetDefaultValue(string)293 Value() string294 SetValue(string)295 TextLength() uint296 WillValidate() bool297 Validity() ValidityState298 ValidationMessage() string299 CheckValidity() bool300 ReportValidity() bool301 SetCustomValidity(string)302 Labels() []Node303 Select()304 SelectionStart() uint305 SetSelectionStart(uint)306 SelectionEnd() uint307 SetSelectionEnd(uint)308 SelectionDirection() string309 SetSelectionDirection(string)310 SetRangeText(string, ...interface{})311 SetSelectionRange(uint, uint, ...string)312 }313 // https://www.w3.org/TR/html52/sec-forms.html#htmloutputelement314 HTMLOutputElement interface {315 HTMLElement316 HtmlFor() DOMTokenList317 Form() HTMLFormElement318 Name() string319 SetName(string)320 Type() string321 DefaultValue() string322 SetDefaultValue(string)323 Value() string324 SetValue(string)325 WillValidate() bool326 Validity() ValidityState327 ValidationMessage() string328 CheckValidity() bool329 ReportValidity() bool330 SetCustomValidity(string)331 Labels() []Node332 }333 // https://www.w3.org/TR/html52/sec-forms.html#htmlprogresselement334 HTMLProgressElement interface {335 HTMLElement336 Value() float64337 SetValue(float64)338 Max() float64339 SetMax(float64)340 Position() float64341 Labels() []Node342 }343 // https://www.w3.org/TR/html52/sec-forms.html#htmlmeterelement344 HTMLMeterElement interface {345 HTMLElement346 Value() float64347 SetValue(float64)348 Min() float64349 SetMin(float64)350 Max() float64351 SetMax(float64)352 Low() float64353 SetLow(float64)354 High() float64355 SetHigh(float64)356 Optimum() float64357 SetOptimum(float64)358 Labels() []Node359 }360 // https://www.w3.org/TR/html52/sec-forms.html#htmlfieldsetelement361 HTMLFieldSetElement interface {362 HTMLElement363 Disabled() bool364 SetDisabled(bool)365 Form() HTMLFormElement366 Name() string367 SetName(string)368 Type() string369 Elements() []HTMLElement370 WillValidate() bool371 Validity() ValidityState372 ValidationMessage() string373 CheckValidity() bool374 ReportValidity() bool375 SetCustomValidity(string)376 }377 // https://www.w3.org/TR/html52/sec-forms.html#htmllegendelement378 HTMLLegendElement interface {379 HTMLElement380 Form() HTMLFormElement381 }382)383// https://www.w3.org/TR/html52/sec-forms.html#enumdef-selectionmode384type SelectionMode string385const (386 SelectionModeSelect SelectionMode = "select"387 SelectionModeStart SelectionMode = "start"388 SelectionModeEnd SelectionMode = "end"389 SelectionModePreserve SelectionMode = "preserve"...

Full Screen

Full Screen

external_hafas_messages.go

Source:external_hafas_messages.go Github

copy

Full Screen

...12}13var hafasMessageHighSelector = cascadia.MustCompile(".himMessagesHigh > div")14var hafasMessageMiddleSelector = cascadia.MustCompile(".himMessagesMiddle > div")15var hafasMessageLowSelector = cascadia.MustCompile(".himMessagesLow > div")16var hafasMessageValiditySelector = cascadia.MustCompile("span.bold")17var hafasMessageContentSelector = cascadia.MustCompile("span:not(.bold)")18var hafasMessageValidityRegex = regexp.MustCompile("^(?P<From>.+?)(?:\\p{Z}-\\p{Z}\\n(?P<To>.+?))?(?::\\p{Z}\\n(?P<Subject>.+?)\\.?)?$")19var hafasMessageIdRegex = regexp.MustCompile("^HIM_Text__(?P<Id>\\d+)$")20func HafasMessagesFromReader(source io.Reader) ([]HafasMessage, error) {21 var err error22 var messages []HafasMessage23 var document *html.Node24 if document, err = html.Parse(source); err != nil {25 return messages, err26 }27 parseMessage := func(node *html.Node, priority HafasMessagePriority) {28 validityNode := hafasMessageValiditySelector.MatchFirst(node)29 contentNode := hafasMessageContentSelector.MatchFirst(node)30 validity := strings.TrimSpace(parseText(validityNode))31 content := strings.TrimSpace(parseText(contentNode))32 var id string33 for _, attr := range node.Attr {34 if attr.Namespace == "" && attr.Key == "id" {35 id = attr.Val36 }37 }38 parsedId := parseRegexGroups(hafasMessageIdRegex, strings.TrimSpace(id))39 parsedValidity := parseRegexGroups(hafasMessageValidityRegex, strings.TrimSpace(validity))40 messages = append(messages, HafasMessage{41 Priority: priority,42 Id: parsedId["Id"],43 From: parsedValidity["From"],44 To: parsedValidity["To"],45 Subject: parsedValidity["Subject"],46 Content: content,47 })48 }49 for _, node := range hafasMessageHighSelector.MatchAll(document) {50 parseMessage(node, HafasMessagePriorityHigh)51 }52 for _, node := range hafasMessageMiddleSelector.MatchAll(document) {53 parseMessage(node, HafasMessagePriorityMiddle)54 }55 for _, node := range hafasMessageLowSelector.MatchAll(document) {56 parseMessage(node, HafasMessagePriorityLow)57 }58 return messages, nil59}...

Full Screen

Full Screen

Validity

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "findlinks1:%v\n", err)6 os.Exit(1)7 }8 for _, link := range visit(nil, doc) {9 fmt.Println(link)10 }11}12func visit(links []string, n *html.Node) []string {13 }14 }15 }16 }17}

Full Screen

Full Screen

Validity

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if doc, err = html.Parse(os.Stdin); err != nil {4 fmt.Fprintf(os.Stderr, "findlinks1: %v\n", err)5 os.Exit(1)6 }7 for _, link := range visit(nil, doc) {8 fmt.Println(link)9 }10}11func visit(links []string, n *html.Node) []string {12 if n.Type == html.ElementNode && n.Data == "a" {13 for _, a := range n.Attr {14 if a.Key == "href" && html.Valid([]byte(a.Val)) {15 links = append(links, a.Val)16 }17 }18 }19 for c := n.FirstChild; c != nil; c = c.NextSibling {20 links = visit(links, c)21 }22}

Full Screen

Full Screen

Validity

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "error: %v\n", err)6 os.Exit(1)7 }8 fmt.Println(html.Valid(doc))9}

Full Screen

Full Screen

Validity

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 if err != nil {4 fmt.Println(err)5 }6 defer resp.Body.Close()7 doc, err := html.Parse(resp.Body)8 if err != nil {9 fmt.Println(err)10 }11 fmt.Println(html.Valid(doc))12}

Full Screen

Full Screen

Validity

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(os.Stdin)4 if err != nil {5 fmt.Fprintf(os.Stderr, "html: %v\n", err)6 os.Exit(1)7 }8 fmt.Println(html.Valid(doc))9}

Full Screen

Full Screen

Validity

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 for _, url := range os.Args[1:] {4 resp, err := http.Get(url)5 if err != nil {6 log.Fatal(err)7 }8 if resp.StatusCode != http.StatusOK {9 resp.Body.Close()10 log.Fatalf("getting %s: %s", url, resp.Status)11 }12 doc, err := html.Parse(resp.Body)13 resp.Body.Close()14 if err != nil {15 log.Fatal(err)16 }17 if !html.Valid(doc) {18 fmt.Printf("%s is not a valid html document\n", url)19 } else {20 fmt.Printf("%s is a valid html document\n", url)21 }22 }23}

Full Screen

Full Screen

Validity

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 doc, err := html.Parse(strings.NewReader(s))4 if err != nil {5 fmt.Printf("html.Parse error: %v\n", err)6 }7 fmt.Println("Document is valid:", html.Valid(doc))8}

Full Screen

Full Screen

Validity

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println(html.EscapeString(str))4 fmt.Println(html.UnescapeString(str))5 fmt.Println(html.Valid([]byte(str)))6 fmt.Println(html.Valid([]byte("<script>alert('Hi!');</script>")))7 fmt.Println(html.Valid([]byte("<script>alert('Hi!');</script>")))8 if err := html.ValidError("<script>alert('Hi!');</script>"); err != nil {9 log.Fatal(err)10 }11}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful