Make instanceof check safer, check if it's an object before using instance of
commit53389ffbf8b1b5ab0d3d9803d7d58c5914d57714
authorEvan Czaplicki <info@elm-lang.org>
dateTue 14 Jan 2014, 11:46 (13 years ago)
parentc9310cc
compiler/Generate/JavaScript/Helpers.hs+2−1
@@ -31,6 +31,7 @@ dotSep vars =
3131obj = dotSep . split
3232
3333equal a b = InfixExpr () OpStrictEq a b
34−instanceof tipe x = InfixExpr () OpInstanceof x (ref tipe)
34+instanceof tipe x =
35+ InfixExpr () OpLAnd (typeof "object" x) (InfixExpr () OpInstanceof x (ref tipe))
3536typeof tipe x = equal (PrefixExpr () PrefixTypeof x) (string tipe)
3637member field x = InfixExpr () OpIn (string field) x