andyli / jQueryExternForHaxe

Unleash the full power of jQuery in Haxe.
http://lib.haxe.org/p/jQueryExtern
65 stars 12 forks source link

Jquery closest should return a JQuery. #1

Closed sledorze closed 13 years ago

sledorze commented 13 years ago

If not then I would be glad to learn why coz I'm fresh to jqueryism :)

andyli commented 13 years ago

Well, because it may return an Array, see lower part of http://api.jquery.com/closest/

cheers, Andy

sledorze commented 13 years ago

Mmmmm.. I see the problem, pretty annoying.. got inference wrong with that. looks like native does not work for methods.. too bad:

public function closest(selector:Dynamic):JQuery; @:native("closest") public function closest_Context(selector:Dynamic, context:Dynamic):Array;

has it been discussed already on the ML?

On Wed, Jun 8, 2011 at 10:57 AM, andyli < reply@reply.github.com>wrote:

Well, because it may return an Array, see lower part of http://api.jquery.com/closest/

cheers, Andy

Reply to this email directly or view it on GitHub: https://github.com/andyli/jQueryExternForHaxe/issues/1#comment_1325424

Stphane Le Dorze

Tel: +33 (0) 6 08 76 70 15

andyli commented 13 years ago

You can use inline to help creating the typed version of the method, something like

inline public function closest_Context(selector:Dynamic, context:Dynamic):Array<Dynamic> {
    return closest(selector, context);
}

Actually you can find that I used this method for cssSet and others in JQueryExtern.

I've proposed on the ML to have method overloading for extern, not sure if Nicolas will implement it. I will try implementing a macro version of method overloading, which seems like possible.

sledorze commented 13 years ago

Yes, in fact both could be typed:

public function closest(selector:Dynamic):JQuery; inline public function closest_Context(selector:Dynamic, context:Dynamic):Array { return untyped closest(selector, context); }

Would you add this to JQueryExtern??? (closest_Context or another naming) I think that JQuery is all about the way one can build inliner. It hurts less in my mind if we add a conventionnal way to call typed version of functions rather than having to trouble shot Dynamic issue and unfold the code over several lines.. :\

What do you think? Stephane

On Wed, Jun 8, 2011 at 12:04 PM, andyli < reply@reply.github.com>wrote:

You can use inline to help creating the typed version of the method, something like

inline public function closest_Context(selector:Dynamic,
context:Dynamic):Array<Dynamic> {
   return closest(selector, context);
}

Actually you can find that I used this method for cssSet and others in JQueryExtern.

I've proposed on the ML to have method overloading for extern, not sure if Nicolas will implement it. I will try implementing a macro version of method overloading, which seems like possible.

Reply to this email directly or view it on GitHub: https://github.com/andyli/jQueryExternForHaxe/issues/1#comment_1325685

Stphane Le Dorze

Tel: +33 (0) 6 08 76 70 15

sledorze commented 13 years ago

oh sorry; I missed the js(" "); stuff..

On Wed, Jun 8, 2011 at 12:11 PM, Stephane Le Dorze < stephane.ledorze@gmail.com> wrote:

Yes, in fact both could be typed:

public function closest(selector:Dynamic):JQuery; inline public function closest_Context(selector:Dynamic, context:Dynamic):Array { return untyped closest(selector, context); }

Would you add this to JQueryExtern??? (closest_Context or another naming) I think that JQuery is all about the way one can build inliner. It hurts less in my mind if we add a conventionnal way to call typed version of functions rather than having to trouble shot Dynamic issue and unfold the code over several lines.. :\

What do you think? Stephane

On Wed, Jun 8, 2011 at 12:04 PM, andyli < reply@reply.github.com>wrote:

You can use inline to help creating the typed version of the method, something like

inline public function closest_Context(selector:Dynamic,
context:Dynamic):Array<Dynamic> {
   return closest(selector, context);
}

Actually you can find that I used this method for cssSet and others in JQueryExtern.

I've proposed on the ML to have method overloading for extern, not sure if Nicolas will implement it. I will try implementing a macro version of method overloading, which seems like possible.

Reply to this email directly or view it on GitHub: https://github.com/andyli/jQueryExternForHaxe/issues/1#comment_1325685

Stphane Le Dorze

Tel: +33 (0) 6 08 76 70 15

Stphane Le Dorze

Tel: +33 (0) 6 08 76 70 15

sledorze commented 13 years ago

Oh but juste realized how much js(".."); is wrong, there's definitively an isue with that multi params..

On Wed, Jun 8, 2011 at 12:11 PM, Stephane Le Dorze < stephane.ledorze@gmail.com> wrote:

oh sorry; I missed the js(" "); stuff..

On Wed, Jun 8, 2011 at 12:11 PM, Stephane Le Dorze < stephane.ledorze@gmail.com> wrote:

Yes, in fact both could be typed:

public function closest(selector:Dynamic):JQuery; inline public function closest_Context(selector:Dynamic, context:Dynamic):Array { return untyped closest(selector, context); }

Would you add this to JQueryExtern??? (closest_Context or another naming) I think that JQuery is all about the way one can build inliner. It hurts less in my mind if we add a conventionnal way to call typed version of functions rather than having to trouble shot Dynamic issue and unfold the code over several lines.. :\

What do you think? Stephane

On Wed, Jun 8, 2011 at 12:04 PM, andyli < reply@reply.github.com

wrote:

You can use inline to help creating the typed version of the method, something like

inline public function closest_Context(selector:Dynamic,
context:Dynamic):Array<Dynamic> {
   return closest(selector, context);
}

Actually you can find that I used this method for cssSet and others in JQueryExtern.

I've proposed on the ML to have method overloading for extern, not sure if Nicolas will implement it. I will try implementing a macro version of method overloading, which seems like possible.

Reply to this email directly or view it on GitHub: https://github.com/andyli/jQueryExternForHaxe/issues/1#comment_1325685

Stphane Le Dorze

Tel: +33 (0) 6 08 76 70 15

Stphane Le Dorze

Tel: +33 (0) 6 08 76 70 15

Stphane Le Dorze

Tel: +33 (0) 6 08 76 70 15

andyli commented 13 years ago

I've commited a change that split closest into closest and closestMulti. From the doc of jQuery, the type signature of closestMulti is

primarily meant to be used internally or by plugin authors.

So I agree it is safe to type the return of closest as JQuery and let ppl use closestMulti if they need the other.

I will have a haxelib release after I align the extern with jQuery 1.6.1.

Thanks for the comment :)

sledorze commented 13 years ago

Thank you for maintening this! ;)

On Thu, Jun 9, 2011 at 1:28 PM, andyli < reply@reply.github.com>wrote:

I've commited a change that split closest into closest and closestMulti. From the doc of jQuery, the type signature of closestMulti is

primarily meant to be used internally or by plugin authors.

So I agree it is safe to type the return of closest as JQuery and let ppl use closestMulti if they need the other.

I will have a haxelib release after I align the extern with jQuery 1.6.1.

Thanks for the comment :)

Reply to this email directly or view it on GitHub: https://github.com/andyli/jQueryExternForHaxe/issues/1#comment_1333579

Stphane Le Dorze

Tel: +33 (0) 6 08 76 70 15