Skip to content

Commit 0bfcd10

Browse files
committed
Fix $interfaceIsEqual general handling of two *js.Object.
Commit cb553f3 fixes the issue for when both *js.Object were undefined. This change makes that fix general and apply when the value of the two *js.Object is anything.
1 parent bf81f38 commit 0bfcd10

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

compiler/prelude/prelude.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,8 @@ var $interfaceIsEqual = function(a, b) {
413413
if (a.constructor !== b.constructor) {
414414
return false;
415415
}
416-
if (a.constructor === $jsObjectPtr && a.object === undefined &&
417-
b.constructor === $jsObjectPtr && b.object === undefined) {
418-
return true;
416+
if (a.constructor === $jsObjectPtr) {
417+
return a.object === b.object;
419418
}
420419
if (!a.constructor.comparable) {
421420
$throwRuntimeError("comparing uncomparable type " + a.constructor.string);

js/js_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ func TestUndefinedEquality(t *testing.T) {
309309
}
310310
}
311311

312+
func TestInterfaceEquality(t *testing.T) {
313+
o := js.Global.Get("Object").New()
314+
var i interface{} = o
315+
if i != o {
316+
t.Fail()
317+
}
318+
}
319+
312320
func TestUndefinedInternalization(t *testing.T) {
313321
undefinedEqualsJsUndefined := func(i interface{}) bool {
314322
return i == js.Undefined

0 commit comments

Comments
 (0)