Commit Graph
217 Commits
Author SHA1 Message Date
Oscar Busk 4f7d2f91d4 Replace angle-bracket-type-assertions with "as" assertion 2018-12-19 01:20:29 +01:00
Nathan Shively-Sanders ef06579ce9 Merge pull request #30234 from leonard-thieu/jquery/text-comment-parameters
[jquery] Allow Text/Comment nodes for some APIs that accept an HTML string.
2018-12-18 13:12:20 -08:00
Jesse Trinity 4e5ac82d0f Merge pull request #31272 from leonard-thieu/jquery/call-signature-arrayLike
[jquery] Fix ArrayLike handling for call signature.
2018-12-13 13:20:08 -08:00
Jesse Trinity ac31768b7b Merge pull request #31164 from leonard-thieu/jquery/off
[jquery] Fix issue with unbinding event handlers for specific event types.
2018-12-13 11:20:13 -08:00
UrielCh cca60bd544 Add Document as JQuery.contents() output encapsulated type. (#31296)
$('iframe').contents() is a JQuery<Document>;
2018-12-12 08:46:22 +00:00
Leonard Thieu 1caac6ef59 [jquery] Fix ArrayLike handling for call signature. 2018-12-11 12:26:21 -05:00
Leonard Thieu 5001e2c42f [jquery] Fix declaration of function parameter for .replaceWith(). 2018-12-09 14:51:34 -05:00
Leonard Thieu 5c9f9cc6ae [jquery] Allow Text/Comment nodes.
See https://github.com/jquery/api.jquery.com/issues/879#issuecomment-175774521.
2018-12-09 14:51:34 -05:00
Leonard Thieu cf2baee61a [jquery] Add originalEvent property to TriggeredEvent. (#31189) 2018-12-09 08:53:44 +00:00
Leonard Thieu fa27dfe857 [jquery] Fix issue with unbinding event handlers for specific event types. 2018-12-07 13:23:48 -05: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 https://github.com/jquery/jquery/blob/354f6036f251a3ce9b24cd7b228b4c7a79001520/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 https://github.com/jquery/jquery/blob/354f6036f251a3ce9b24cd7b228b4c7a79001520/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