Saltarelle / SaltarelleCompiler

C# to JavaScript compiler – Now http://bridge.net
http://saltarelle-compiler.com
Other
297 stars 74 forks source link

Saltarelle rewrites Mixing expression $.expr[':'] to $["expr[':']"] #442

Closed thecoderok closed 7 years ago

thecoderok commented 8 years ago

I'm trying to write jQuery selector extension and I need to get resulting JS:

$.expr[':'].focusable = function jQuerySelectorExtensions$Focusable(element) {
    return $tab_$jQuerySelectorExtensionsImpl.$focusable(element, !isNaN(parseInt($(element).attr('tabindex'), 10)));
};

So I decorated my class with Mixin attribute:

[Mixin("$.expr[':']")]

But Saltarelle rewrites expression as:

$["expr[':']"].focusable

And obviously it does not work. Is there a fix or workaround?

geoffreymcgill commented 7 years ago

I tried your Mixin sample in Bridge and it compiles correctly.

http://deck.net/72d7000a5993bf4204f7b382330b7fdc

public class Program
{
    public static void Main()
    {
        Item.Focusable();
    }
}

[Mixin("$.expr[':']")]
public static class Item
{
    public static void Focusable() {
        Console.WriteLine("focus");
    }
}

This functionality is working in Bridge, but unfortunately a fix for this defect will not be included in Saltarelle.

If you're interested in upgrading your project to Bridge, please let me know. We're looking for a project that the Bridge team can work closely with to assist during the process and document (+fix) any trouble spots.