Skip to content

Commit ce23876

Browse files
committed
Sync with latest version of gopherjs. BUG: some tests are failing.
1 parent 7776437 commit ce23876

File tree

4 files changed

+5697
-4844
lines changed

4 files changed

+5697
-4844
lines changed

jquery.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,28 @@ const (
5050
)
5151

5252
type JQuery struct {
53-
o js.Object
53+
o *js.Object
5454
Jquery string `js:"jquery"`
5555
Selector string `js:"selector"` //deprecated according jquery docs
5656
Length int `js:"length"`
5757
Context string `js:"context"`
5858
}
5959

6060
type Event struct {
61-
js.Object
62-
KeyCode int `js:"keyCode"`
63-
Target js.Object `js:"target"`
64-
CurrentTarget js.Object `js:"currentTarget"`
65-
DelegateTarget js.Object `js:"delegateTarget"`
66-
RelatedTarget js.Object `js:"relatedTarget"`
67-
Data js.Object `js:"data"`
68-
Result js.Object `js:"result"`
69-
Which int `js:"which"`
70-
Namespace string `js:"namespace"`
71-
MetaKey bool `js:"metaKey"`
72-
PageX int `js:"pageX"`
73-
PageY int `js:"pageY"`
74-
Type string `js:"type"`
61+
*js.Object
62+
KeyCode int `js:"keyCode"`
63+
Target *js.Object `js:"target"`
64+
CurrentTarget *js.Object `js:"currentTarget"`
65+
DelegateTarget *js.Object `js:"delegateTarget"`
66+
RelatedTarget *js.Object `js:"relatedTarget"`
67+
Data *js.Object `js:"data"`
68+
Result *js.Object `js:"result"`
69+
Which int `js:"which"`
70+
Namespace string `js:"namespace"`
71+
MetaKey bool `js:"metaKey"`
72+
PageX int `js:"pageX"`
73+
PageY int `js:"pageY"`
74+
Type string `js:"type"`
7575
}
7676

7777
type JQueryCoordinates struct {
@@ -198,7 +198,7 @@ func Now() float64 {
198198
}
199199

200200
//static function
201-
func Unique(arr js.Object) js.Object {
201+
func Unique(arr *js.Object) *js.Object {
202202
return js.Global.Get(JQ).Call("unique", arr)
203203
}
204204

@@ -208,11 +208,11 @@ func (j JQuery) Each(fn func(int, interface{})) JQuery {
208208
return j
209209
}
210210

211-
func (j JQuery) Underlying() js.Object {
211+
func (j JQuery) Underlying() *js.Object {
212212
return j.o
213213
}
214214

215-
func (j JQuery) Get(i ...interface{}) js.Object {
215+
func (j JQuery) Get(i ...interface{}) *js.Object {
216216
return j.o.Call("get", i...)
217217
}
218218

@@ -760,7 +760,7 @@ func (j JQuery) Serialize() string {
760760
return j.o.Call("serialize").String()
761761
}
762762

763-
func (j JQuery) SerializeArray() js.Object {
763+
func (j JQuery) SerializeArray() *js.Object {
764764
return j.o.Call("serializeArray")
765765
}
766766

@@ -796,12 +796,12 @@ func GetScript(i ...interface{}) Deferred {
796796
return Deferred{js.Global.Get(JQ).Call("getScript", i...)}
797797
}
798798

799-
func (d Deferred) Promise() js.Object {
799+
func (d Deferred) Promise() *js.Object {
800800
return d.Call("promise")
801801
}
802802

803803
type Deferred struct {
804-
js.Object
804+
*js.Object
805805
}
806806

807807
func (d Deferred) Then(fn ...interface{}) Deferred {

test/test/index.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package test
1+
package main
22

33
import (
4+
"github.com/albrow/jquery"
45
"github.com/gopherjs/gopherjs/js"
5-
"github.com/gopherjs/jquery"
66
QUnit "github.com/rusco/qunit"
77
"strconv"
88
"strings"
@@ -32,12 +32,12 @@ func (s EvtScenario) Teardown() {
3232

3333
var jQuery = jquery.NewJQuery //convenience
3434

35-
func getDocumentBody() js.Object {
35+
func getDocumentBody() *js.Object {
3636
return js.Global.Get("document").Get("body")
3737
}
3838

3939
func stringify(i interface{}) string {
40-
return js.Global.Get("JSON").Call("stringify", i).Str()
40+
return js.Global.Get("JSON").Call("stringify", i).String()
4141
}
4242

4343
func log(i ...interface{}) {
@@ -74,7 +74,7 @@ var (
7474
countKarl = 0
7575
)
7676

77-
func asyncEvent(accept bool, i int) js.Object {
77+
func asyncEvent(accept bool, i int) *js.Object {
7878

7979
dfd := jquery.NewDeferred()
8080

@@ -478,7 +478,7 @@ func main() {
478478

479479
sa := jQuery(evt.Target).SerializeArray()
480480
for i := 0; i < sa.Length(); i++ {
481-
collectResults += sa.Index(i).Get("name").Str()
481+
collectResults += sa.Index(i).Get("name").String()
482482
}
483483
assert.Equal(collectResults, "abcde", "SerializeArray")
484484
evt.PreventDefault()
@@ -494,7 +494,7 @@ func main() {
494494
QUnit.Test("On,One,Off,Trigger", func(assert QUnit.QUnitAssert) {
495495

496496
fn := func(ev jquery.Event) {
497-
assert.Ok(!ev.Data == js.Undefined, "on() with data, check passed data exists")
497+
assert.Ok(ev.Data != js.Undefined, "on() with data, check passed data exists")
498498
assert.Equal(ev.Data.Get("foo"), "bar", "on() with data, Check value of passed data")
499499
}
500500

@@ -564,16 +564,16 @@ func main() {
564564

565565
jQuery(FIX).On(jquery.CLICK, func(e jquery.Event) {
566566

567-
jQuery(FIX).Find("div").Each(func(i int, elem interface{}) interface{} {
567+
//jQuery(FIX).Find("div").Each(func(i int, elem interface{}) interface{} {
568+
jQuery(FIX).Find("div").Each(func(i int, elem interface{}) {
568569

569570
style := jQuery(elem).Get(0).Get("style")
570-
if style.Get("color").Str() != "blue" {
571+
if style.Get("color").String() != "blue" {
571572
style.Set("color", "blue")
572573
} else {
573574
blueCount += 1
574575
style.Set("color", "")
575576
}
576-
return nil
577577

578578
})
579579
})
@@ -612,13 +612,13 @@ func main() {
612612
}).SetCss("font-weight", "bold")
613613

614614
countFontweight := 0
615-
jQuery(FIX).Find("div").Each(func(i int, elem interface{}) interface{} {
615+
jQuery(FIX).Find("div").Each(func(i int, elem interface{}) {
616616

617617
fw := jQuery(elem).Css("font-weight")
618618
if fw == "bold" || fw == "700" {
619619
countFontweight += 1
620620
}
621-
return nil
621+
622622
})
623623
assert.Equal(countFontweight, 2, "2 divs should have font-weight = 'bold'")
624624

0 commit comments

Comments
 (0)