From 86e45eece59da83db1c5de19931bcfacfe8cec83 Mon Sep 17 00:00:00 2001 From: James Fisher Date: Wed, 17 Jul 2013 23:06:52 +0100 Subject: [PATCH] jQuery (inner|outer)(Width|Height) are setters as well as getters This undocumented behavior is described in an open issue: https://github.com/jquery/api.jquery.com/issues/98 --- jquery/jquery-tests.ts | 24 ++++++++++++++++++++---- jquery/jquery.d.ts | 22 ++++++++++++++-------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index db8309e062..c2ab118e2d 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1718,14 +1718,30 @@ function test_index() { $('div').html('Index: ' + foobar); } -function test_innedHeight() { +function test_innerHeight() { var p = $("p:first"); $("p:last").text("innerHeight:" + p.innerHeight()); + p.innerHeight(p.innerHeight() * 2).innerHeight(); } function test_innerWidth() { var p = $("p:first"); $("p:last").text("innerWidth:" + p.innerWidth()); + p.innerWidth(p.innerWidth() * 2).innerWidth(); +} + +function test_outerHeight() { + var p = $("p:first"); + $("p:last").text("outerHeight:" + p.outerHeight(true)); + p.outerHeight(p.outerHeight() * 2).outerHeight(); + p.outerHeight(p.outerHeight() * 2, true).outerHeight(); +} + +function test_outerWidth() { + var p = $("p:first"); + $("p:last").text("outerWidth:" + p.outerWidth(true)); + p.outerWidth(p.outerWidth() * 2).outerWidth(); + p.outerWidth(p.outerWidth() * 2, true).outerWidth(); } function test_insertAfter() { @@ -2272,15 +2288,15 @@ function test_parseHTML() { str = "hello, my name is jQuery.", html = $.parseHTML( str ), nodeNames = []; - + // Append the parsed HTML $log.append( html ); - + // Gather the parsed HTML's node names $.each( html, function( i, el ) { nodeNames[i] = "
  • " + el.nodeName + "
  • "; }); - + // Insert the node names $log.append( "

    Node Names:

    " ); $( "
      " ) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 1f19698146..e5ca2bd508 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -83,11 +83,11 @@ interface JQueryCallback { /* Allows jQuery Promises to interop with non-jQuery promises */ -interface JQueryGenericPromise { - then(onFulfill: (value: T) => U, onReject?: (reason) => U): JQueryGenericPromise; - then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (reason) => U): JQueryGenericPromise; - then(onFulfill: (value: T) => U, onReject?: (reason) => JQueryGenericPromise): JQueryGenericPromise; - then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (reason) => JQueryGenericPromise): JQueryGenericPromise; +interface JQueryGenericPromise { + then(onFulfill: (value: T) => U, onReject?: (reason) => U): JQueryGenericPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (reason) => U): JQueryGenericPromise; + then(onFulfill: (value: T) => U, onReject?: (reason) => JQueryGenericPromise): JQueryGenericPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (reason) => JQueryGenericPromise): JQueryGenericPromise; } /* @@ -102,9 +102,9 @@ interface JQueryPromise { // Deprecated - given no typings pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise; - then(onFulfill: (value: T) => U, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; - then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; - then(onFulfill: (value: T) => U, onReject?: (...reasons) => JQueryGenericPromise, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (value: T) => U, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (...reasons) => U, onProgress?: (...progression) => any): JQueryPromise; + then(onFulfill: (value: T) => U, onReject?: (...reasons) => JQueryGenericPromise, onProgress?: (...progression) => any): JQueryPromise; then(onFulfill: (value: T) => JQueryGenericPromise, onReject?: (...reasons) => JQueryGenericPromise, onProgress?: (...progression) => any): JQueryPromise; // Because JQuery Promises Suck @@ -448,14 +448,20 @@ interface JQuery { height(func: (index: any, height: any) => any): JQuery; innerHeight(): number; + innerHeight(value: number): JQuery; + innerWidth(): number; + innerWidth(value: number): JQuery; offset(): { left: number; top: number; }; offset(coordinates: any): JQuery; offset(func: (index: any, coords: any) => any): JQuery; outerHeight(includeMargin?: boolean): number; + outerHeight(value: number, includeMargin?: boolean): JQuery; + outerWidth(includeMargin?: boolean): number; + outerWidth(value: number, includeMargin?: boolean): JQuery; position(): { top: number; left: number; };