Commit Graph

208 Commits

Author SHA1 Message Date
Leonard Thieu
cf2baee61a [jquery] Add originalEvent property to TriggeredEvent. (#31189) 2018-12-09 08:53:44 +00:00
Leonard Thieu
bf2beee34c [jquery] Fix no-angle-bracket-type-assertion violations. 2018-11-24 09:45:54 -05:00
Leonard Thieu
e573d98516 [jquery] Add tests for JQuery.TypeEventHandlers. 2018-11-24 09:43:08 -05:00
Leonard Thieu
33c6e58f6e [jquery] Add missing TTarget type parameter to touch events. 2018-11-24 09:43:08 -05:00
Leonard Thieu
db83bc7200 [jquery] Don't use a separate type parameter for the type of this in event handlers.
A separate type parameter is unnecessary as `this` and `currentTarget` reference the same object.
2018-11-24 09:43:08 -05:00
Leonard Thieu
3a54bad068 [jquery] Add support for touch events.
Fixes test failures in `viewporter` due to changes in jQuery Events API.
2018-11-24 09:43:07 -05:00
Leonard Thieu
00c546398c [jquery] Add support for event types that have shorthand methods. 2018-11-24 09:43:04 -05:00
Leonard Thieu
f13af8beb0 [jquery] Improve declaration of Events API.
* Introduced the concept of a triggered event. A triggered event is a jQuery event that has been triggered (either manually by `.trigger()` or `.triggerHandler()`, or automatically by the user agent). Many properties on an event are not set until it has been triggered. Triggered events are now represented by `JQuery.TriggeredEvent`. `JQuery.Event` represents the object returned from the `jQuery.Event` constructor and serves as the base type for all jQuery events.

* Added a type parameter for `currentTarget` (`TCurrentTarget`). Previously, `currentTarget` was set to the type of `delegateTarget`. This was only correct for events received from directly bound event handlers. This allows delegate bound event handlers to specify the correct type of `currentTarget`.

* Added a type parameter for `target` (`TTarget`). Previously, `target` was set to the type of `delegateTarget`. This was not always correct. For delegate bound event handlers, `target` can be `delegateTarget` or any of its descendents. The exact type of `target` cannot be known until run time, so consumers should use a type assertion.

* Changed methods that bind event handlers to more accurately reflect the event object received through the callback. Both direct and delegate binding are now properly handled. This also includes a framework for providing more specific events for known event types.
2018-11-24 09:43:03 -05:00
Leonard Thieu
c1ec1c28e5 [jquery] Remove JQuery.EventHandlerBase<TContext = any, JQuery.Event> from handler types.
Handler types previously included `JQuery.EventHandlerBase<TContext = any, JQuery.Event>`. This was a fix to what turned out to be a problem with `jQuery.proxy`. That issue was properly fixed by https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29930.
2018-11-24 09:43:03 -05:00
Leonard Thieu
32e0482fb5 [jquery] Remove jQuery.Event(EventLike) signatures and EventLike interface.
These are undocumented and don't appear to be intended to be public.
2018-11-24 09:43:02 -05:00
Leonard Thieu
50b56a19ce [jquery] Remove jQuery.event.props.
See https://jquery.com/upgrade-guide/3.0/#breaking-change-jquery-event-props-and-jquery-event-fixhooks-removed.
2018-11-24 09:43:02 -05:00
Leonard Thieu
e64bea6d88 [jquery] Remove jQuery.event.fixHooks.
See https://jquery.com/upgrade-guide/3.0/#breaking-change-jquery-event-props-and-jquery-event-fixhooks-removed.
2018-11-24 09:43:01 -05:00
Leonard Thieu
16770fa6e1 [jquery] Add deprecation notice for Event.which. 2018-11-24 09:43:01 -05:00
Andy
141d1cc870
And tslint disables for no-angle-bracket-type-assertion (#30592) 2018-11-16 12:20:58 -08:00
Andy
307a9a0181
jquery: Add no-unnecessary-type-assertion disables (#30319) 2018-11-06 11:26:42 -08:00
Leonard Thieu
c6fe757c0d [jquery] Fix TContext declaration of jQuery.proxy on wrong value's type. (#29930)
* [jquery] Match parameter names to documentation more closely.

* [jquery] Add documentation to parameters.

* [jquery] Fix `TContext` declaration on wrong value's type.

Declaring `this` as `TContext` on the input function ensures that it can handle having its context changed to `TContext`. Declaring `this` on the output function is not important because the function will be already defined. It can also get in the way when passing a callback to a function whose callback parameter has `this` declared.

* [jquery] Drop constraint from `TContext`.

It's not really necessary and it is possible to pass primitives as the context.
2018-10-22 09:28:30 -07:00
Leonard Thieu
59b32e5353 [jquery] Add self-extending overloads of jQuery.extend(). (#29924) 2018-10-22 09:25:28 -07:00
Leonard Thieu
5348b35343 [jquery] Split up declarations to stay under GitHub limits. Improve documentation. (#29831)
* [jquery] Split `JQueryStatic` into its own file.

* [jquery] Split `JQuery` into its own file.

* [jquery] Split `JQuery` namespace into its own file.

* [jquery] Split legacy types into their own file.

* [jquery] Remove hard line breaks from documentation descriptions.

WebStorm treats line breaks in descriptions as line breaks when rendering descriptions in tooltips. This causes unintentional early wrapping of text.

* [jquery] Remove extra line after descriptions.

* [jquery] Audit lint rules.

* [jquery] Improve documentation for API methods which have had their signatures unified.
2018-10-18 09:23:20 -07:00
Leonard Thieu
bbf1adeeac [jquery] Add preDispatch and postDispatch methods. Fix weak type issues. (#29750)
* [jquery] Add `preDispatch` and `postDispatch` methods.

See https://github.com/jquery/api.jquery.com/issues/752.

* [jquery] Fix weak type issue for `SpecialEventHook`.

* [jquery] Fix weak type issue for `FixHook`.

* [jquery] Add interface for `jQuery.valHooks`.

* [jquery] Fix weak type issue for `ValHook`.

* [jquery] Add interface for `jQuery.cssHooks`.

* [jquery] Properties on `CSSHook` are optional.

* [jquery] Use polymorphic `this` for `settings` parameter.

* [jquery] Wrap `StatusCodeCallbacks` in a region.

* [jquery] Split `@since` tag for consistency.
2018-10-16 14:42:42 -07:00
Leonard Thieu
c3cbb348e2 [jquery] Add includeMargin parameter to .outerHeight() and .outerWidth() setters. (#29756)
* [jquery] Add `includeMargin` parameter to `.outerHeight()` and `.outerWidth()` setters.

See 354f6036f2/test/unit/dimensions.js (L477-L484).

* [jquery-awesome-cursor] Add missing `dom` lib target.

* [jquery-toast-plugin] Add missing `dom` lib target.

* [jquery.growl] Add missing `dom` lib target.

* [materialize-css] Disable `unified-signatures` rule for plugin overloads.

These overloads follow the jQuery plugin pattern and are effectively separate methods.

* [ng-cordova] Update promise types to be compatible with changes from `ng.IPromise`.

Ref: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/23115

* [ng-tags-input] Add missing `dom` lib target.

* [p-loading] Add missing `dom` lib target.

* [summernote] Add missing `dom` lib target.

* [swig-email-templates] Add missing `dom` lib target.

* [materialize-css] Unify signatures according to feedback.

See https://github.com/DefinitelyTyped/DefinitelyTyped/pull/29756#pullrequestreview-165249412.
2018-10-16 10:15:06 -07:00
Leonard Thieu
1cfcb1ad3b [jquery] Add Animation API. Fix weak type issue for jQuery.speed. (#29712)
* [jquery] Add Animation API.

See https://blog.jquery.com/2012/08/09/jquery-1-8-released/.

* [jquery] Organize Effects section.

* [jquery] Fix weak type issue for `jQuery.speed`.

* [jquery] Fix minor documentation issues.

* [jquery] `stop` and `timer` don't need to be properties.
2018-10-15 17:47:42 -07:00
Leonard Thieu
20529b02e1 [jquery] Add event extensions API. (#29687)
* [jquery] Add event extensions API.

See https://learn.jquery.com/events/event-extensions/.

* [jquery] Make the errors go away.
2018-10-12 14:23:07 -07:00
Leonard Thieu
86fd332d85 [jquery] Remove removed parameters from EasingMethod. (#29663)
These were never available in jQuery 3.0+.
2018-10-11 14:26:08 -07:00
Leonard Thieu
abbce5d159 [jquery] Documentation improvements (#29658)
* [jquery] Fix code for example not rendering in VS Code autocomplete.

VS Code does not render the code block of the last example in the autocomplete tooltip (but does in the hover tooltip). This is fixed by adding an additional line terminated by a zero-width space. There doesn't appear to be an obvious pattern to what causes this and there may be other incidences of this bug in the declarations.

* [jquery] Improve formatting of documentation for unified signatures in tooltips.

Documentation for unified signatures is also unified. This means that documentation for a parameter will contain documentation from all the parameters that it's composed of. VS Code and WebStorm render this as one continuous line. This makes it confusing as it's not obvious which parts of documentation apply to a parameter.

To remedy this, parameters are formatted as a bulletted list. `<br>` tags are necessary to force line breaks in WebStorm. The list also cannot start on the first line. To force the first line break, the `<br>` tag is used for WebStorm. For VS Code, a non-empty body must follow the parameter name on its line. A Braille Pattern Blank could be used here but to provide a more intuitive and consistent experience, VS Code's format for rendering parameter info is mimicked instead. The `@` symbol must be encoded to prevent `@param` from being parsed as a JSDoc tag.

Note: VS Code renders the `<br>` tags literally and there does not appear to be a way to hide them.
2018-10-11 11:45:40 -07:00
Leonard Thieu
d883a9fd50 [jquery] Documentation improvements. Add jQuery.cleanData and overloads for jQuery.getScript and Data APIs. (#29573)
* [jquery] Introduce interface for `jQuery.fx`.

* [jquery] Attach `jQuery.Deferred` documentation to correct symbol.

* [jquery] Convert `jQuery.Callbacks` to an interface.

This change is purely for consistency with similar properties (e.g. `jQuery.Deferred`, `jQuery.Event`).

* [jquery] For `JQuery`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] For `JQueryStatic`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] For `JQuery.Event`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] For `JQuery.Callbacks`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] For `JQuery.PromiseBase`/`JQuery.Deferred`, reduce examples to only those relevant to the overload and use shorter template for code-only examples.

* [jquery] Consistent ordering.

* [jquery] Add `jQuery.getScript(options)`.

See https://github.com/jquery/api.jquery.com/issues/1052.

* [jquery] Fix documentation for this one overload of `jQuery.proxy`.

* [jquery] Accept `Document`, `Window`, and `JQuery.PlainObject` for the `element` parameter of Data APIs.

See 354f6036f2/test/unit/data.js (L142-L164) and https://github.com/jquery/api.jquery.com/issues/1035.

* [jquery] Add `jQuery.cleanData`.

See https://github.com/jquery/api.jquery.com/issues/996.
2018-10-09 08:34:57 -07:00
Leonard Thieu
acbdedd544 [jquery] Copied event properties are writable. (#29520)
* [jquery] Fix indentation.

* [jquery] Copied event properties are writable.

* [jquery] Formatting. Arrange `Event` members according to origin.
2018-10-08 09:03:01 -07:00
Leonard Thieu
1c988f15eb [jquery][sizzle] Add detailed deprecation notices and jQuery.nodeName(), jQuery.expr, and jQuery.easing. (#29503)
* [jquery] Add detailed deprecation notices.

* [jquery] Add `jQuery.nodeName()`.

* [sizzle] Add named interfaces for `Selectors` properties.

* [jquery] Add `jQuery.expr`.

* [jquery] Add `jQuery.easing`.

* [jquery] Improve formatting of `@deprecated` tags.

WebStorm will not add padding between the description and deprecated text. To improve readability, a zero-width space and space is added to deprecated text to force padding.

VS Code will collapse white space causing detailed deprecation notices to start adjacent to the `@deprecated` tag if there is no header. A minimal header is added where necessary.

WebStorm renders line breaks in JSDoc. This may cause unintentional wrapping of text for `@deprecated` tags. To avoid this, line breaks are not used in deprecated text unless it's intended to render a line break there.

This also fixes broken non-http `@link` tags and ensures that they render consistently.
2018-10-06 21:46:18 +01:00
boriskor
823da0de4e [jquery] Change all HTMLElement to be Element (#29282)
* [jquery] Change all `HTMLElement` to be `Element`

* [jquery/v2] remove wrong `parseHTML` overload
2018-10-03 11:53:04 -07:00
Leonard Thieu
7c0825a58c [jquery] Drop type guards from isNumeric()/isPlainObject() and improve declarations of jQuery.data()/.data()/jQuery.css() (#29381)
* [jquery] `isNumeric` can not be a user defined type guard.

`isNumeric` can return true for strings in addition to numbers, but only for a subset of either. It'll return false for NaN (which TypeScript treats as a number) and for strings which cannot be parsed as a number.

* [jquery] `isPlainObject` can not be a user defined type guard.

Due to the imprecise way with how `PlainObject` is declared, `isPlainObject` can not be a user defined type guard.

* [jquery] Use https for links.

* [jquery] Fix link for `JQuery.jquery`.

* [jquery] Remove empty line before `@deprecated`.

For consistent formatting since examples were added.

* [jquery] Document additional `extend` parameters.

* [jquery] Improve declarations of `data()` to catch unintentionally passing `undefined` as a value.

This handles the more likely case of users passing a value that is possibly undefined.

* [jquery] Improve declaration of `css()`.

* [jquery] Minor improves to `proxy()` documentation.

* [jquery] Fix region folding for WebStorm.

WebStorm uses `// #region` to designate a region start while VS Code uses `// region`. They can both (must, in this case) be terminated using `// #endregion`. Using both `// #endregion` and `// endregion` results in odd behavior in both editors.
2018-10-02 11:37:07 -07:00
Leonard Thieu
e81760c6f8 [jquery] trigger/triggerHandler accept boolean values for extraParameters. (#29286)
See https://liveweave.com/BTLAFI
2018-10-01 20:58:32 -07:00
Leonard Thieu
895f0a91de [jquery] Add examples documentation. (#29295) 2018-10-01 20:53:26 -07:00
Dainel Yule
5dc1165fb1 [jquery] Change return type of the index function to be Element instead of HTMLElement (#29212)
This reflects the fact that jQuery can be used to select other kinds of elements such as SVGElement
2018-09-26 21:22:11 +01:00
Andrew Casey
234b2170f0
Merge pull request #28888 from leonard-thieu/jquery/remove-const-enums
[jquery] Remove usages of `const enum`.
2018-09-24 11:25:44 -07:00
Leonard Thieu
7d71ffdae2 [jquery] Fix issue with resolving Symbol when used with ES5. 2018-09-18 06:26:45 -04:00
Nathan Shively-Sanders
11ce407429
Merge pull request #28769 from leonard-thieu/jquery/promise-compatibility
[jquery] Fix regression with assignability of jQuery Promises to Promise.
2018-09-17 15:13:03 -07:00
Terry Mun
bf4b60d283 Updated tests to include prepending to document fragment 2018-09-15 11:51:22 +02:00
Terry Mun
8d250ffcd8 prependTo() and appendTo() should work with Element or DocumentFragment 2018-09-15 11:43:11 +02:00
Leonard Thieu
6912302128 [jquery] Fix region folding for VS Code. 2018-09-14 08:16:42 -04:00
Leonard Thieu
3aa7d5edd1 [jquery] Remove usages of const enum.
`Mouse` and `Key` were provided for convenience. Their presence is problematic though as they're not actually part of the jQuery API, cause the `JQuery` namespace to become a value, and doesn't work with the `isolatedModules` option.
2018-09-14 08:16:35 -04:00
Terry Mun
2faff4872d Added author credits 2018-09-11 13:38:05 +02:00
Terry Mun
9cd2d6f51a .appendTo() should accept a document fragment as an argument (not just Element) 2018-09-11 13:29:18 +02:00
Leonard Thieu
23dbcc7145 [jquery] Fix regression with assignability of jQuery Promises to Promise. 2018-09-10 19:07:34 -04:00
denisname
24973f21e7 JQuery: HTMLSelectElement and arrays (#27810)
* Change to work better with arrays and HTMLSelectElement

See pull request description

* document.body and document.documentElement are possibly null in TypeScript@next

* Select2 fix test

* Change according to review comments

* Fix JQuery<any> in TS 2.3

* CI failed, force to run again

* document.body is not null anymore

* Rename params

* Add a comment above the `tslint:disable`s

* Wrong line :/

I went too fast
2018-08-15 08:48:04 -07:00
Andy
73227df0fd
Jquery: change disables in tslint.json to disables in specific files (#27919) 2018-08-07 12:11:07 -07:00
FUJI Goro
9fa7394da1 [@types/jquery] fix: let jQuery's insertAfter / insertBefore accept Node and JQuery<Node> (#27404)
* fix: let jQuery's insertAfter / insertBefore accept JQuery<HTMLElement> as well as HTMLElement

* jquery now requires typescript 2.4

* fix jQuery dts to compile on TypeScript 2.3
2018-07-20 17:56:39 -07:00
Leonard Thieu
63867fb112 [jquery] offset can accept a partial Coordinates object. (#27437) 2018-07-20 13:31:21 +01:00
segayuu
1a07f27101 [@types/Bluebird] Make iterative methods rigid types without type parameters. (#27216)
* Resolve bluebird(Array) method

* upgrade typescript version from bluebird-global

* move testfile
Reason: There are too many type definition files
  depending on jquery and it can not be managed.

* upgrade typescript version from bluebird require packages

* fix lint error: use-default-type-parameter
2018-07-12 09:23:46 -07:00
Nathan Shively-Sanders
3c9c7fdacb
Merge pull request #26674 from leonard-thieu/jquery/jquerystatic-type-parameter
[jquery] Remove type parameter from `JQueryStatic`
2018-06-19 12:46:05 -07:00
Leonard Thieu
f3b10b2269 [jquery] Add tests to cover the changed APIs. 2018-06-19 13:56:49 -04:00
Leonard Thieu
9e427aa322 [jquery] Improve lint compliance. 2018-06-19 13:41:49 -04:00