From 987e0003329cfd0c7723c4621d4c42d850b74d25 Mon Sep 17 00:00:00 2001 From: Sean Hill Date: Fri, 15 Feb 2013 13:09:07 -0600 Subject: [PATCH 1/2] Add definition for selector property. --- jquery/jquery-tests.ts | 7 +++++++ jquery/jquery.d.ts | 1 + 2 files changed, 8 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 65235e105..29da1c542 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -2220,6 +2220,13 @@ function test_prop() { var title: string = $('option:selected', this).prop('title'); } + +function test_selector() { + var $main = $('#main'); + var $mainDivs = $('div', $main); + return $mainDivs.selector == '#main div'; +} + function test_text() { var str = $("p:first").text(); $("p:last").html(str); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index cdae1d8ec..4d650c98f 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -700,6 +700,7 @@ interface JQuery { PROPERTIES ***********/ length: number; + selector: string; [x: string]: HTMLElement; [x: number]: HTMLElement; From 4c5cf3c4b0092d009401d0a4aea950f6f61bb646 Mon Sep 17 00:00:00 2001 From: Sean Hill Date: Fri, 15 Feb 2013 13:30:45 -0600 Subject: [PATCH 2/2] Allow MustacheWriter to be called as a function with the view as the parameter. For example, the documentation for Mustache.js shows the following: var compiledTemplate = Mustache.compile(stringTemplate); var templateOutput = compiledTemplate(templateData); --- mustache/mustache-tests.ts | 5 ++++- mustache/mustache.d.ts | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mustache/mustache-tests.ts b/mustache/mustache-tests.ts index 744e85585..9b42131ef 100644 --- a/mustache/mustache-tests.ts +++ b/mustache/mustache-tests.ts @@ -5,4 +5,7 @@ var output = Mustache.render("{{title}} spends {{calc}}", view); var person; var template = "

{{firstName}} {{lastName}}

Blog: {{blogURL}}"; -var html = Mustache.to_html(template, person); \ No newline at end of file +var html = Mustache.to_html(template, person); + +var writer = Mustache.compile(template); +var writerOutput = writer(view); diff --git a/mustache/mustache.d.ts b/mustache/mustache.d.ts index 1bc1a6cdd..c1be75afd 100644 --- a/mustache/mustache.d.ts +++ b/mustache/mustache.d.ts @@ -24,6 +24,7 @@ interface MustacheContext { } interface MustacheWriter { + (view: any): string; clearCache(); compile(template: string, tags); compilePartial(name, template, tags); @@ -42,6 +43,7 @@ interface MustacheStatic { parse(template: string, tags); clearCache(): MustacheWriter; + compile(template: string): MustacheWriter; compile(template: string, tags): MustacheWriter; compilePartial(name: string, template: string, tags): MustacheWriter; compileTokens(tokens, template: string): MustacheWriter;