浏览代码

fixed JQuery.cur in closure (use $this instead of this), close #2218

Nicolas Cannasse 11 年之前
父节点
当前提交
96d23df387
共有 2 个文件被更改,包括 3 次插入1 次删除
  1. 2 0
      genjs.ml
  2. 1 1
      std/js/JQuery.hx

+ 2 - 0
genjs.ml

@@ -381,6 +381,8 @@ let rec gen_call ctx e el in_value =
 		spr ctx "(";
 		concat ctx "," (gen_value ctx) params;
 		spr ctx ")";
+	| TLocal { v_name = "__js__" }, [{ eexpr = TConst (TString "this") }] ->
+		spr ctx (this ctx)
 	| TLocal { v_name = "__js__" }, [{ eexpr = TConst (TString code) }] ->
 		spr ctx (String.concat "\n" (ExtString.String.nsplit code "\r\n"))
 	| TLocal { v_name = "__instanceof__" },  [o;t] ->

+ 1 - 1
std/js/JQuery.hx

@@ -390,7 +390,7 @@ extern class JQuery implements ArrayAccess<Element> {
 	//static function is*, makeArray, map, merge, noop, now, param, proxy, sub, trim, type, unique
 
 	private static inline function get_cur() : JQuery {
-		return untyped __js__("$(this)");
+		return untyped $(__js__("this"));
 	}
 
 	private static function __init__() : Void untyped {