aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Selector:Manipulation: Fix DOM manip within template contentsMichał Gołębiowski-Owczarek2022-11-161-3/+2
| | | | | | | | | | | | | | | | | | | | | | The `<template/>` element `contents` property is a document fragment that may have a `null` `documentElement`. In Safari 16 this happens in more cases due to recent spec changes - in particular, even if that document fragment is explicitly adopted into an outer document. We're testing both of those cases now. The crash used to happen in `jQuery.contains` which is an alias for `Sizzle.contains` in jQuery 3.x. The Sizzle fix is at jquery/sizzle#490, released in Sizzle `2.3.8`. This version of Sizzle is included in the parent commit. A fix similar to the one from gh-5158 has also been applied here to the `selector-native` version. Fixes gh-5147 Closes gh-5159 Ref jquery/sizzle#490 Ref gh-5158
* CSS: Return `undefined` for whitespace-only CSS variable values (#5120)Michał Gołębiowski-Owczarek2022-10-031-4/+24
| | | | | | | | | | | | | | | | | | | The spec requires that CSS variable values are trimmed. In browsers that do this - mainly, Safari, but also Firefox if the value only has leading whitespace - we currently return undefined; in other browsers, we return an empty string as the logic to fall back to undefined happens before trimming. This commit adds another explicit callback to `undefined` to have it consistent across browsers. Also, more explicit comments about behaviors we need to work around in various browsers have been added. Closes gh-5120 Ref gh-5106 (cherry picked from commit 7eb0019640a5856c42b451551eb7f995d913eba9)
* CSS: Don’t trim whitespace of undefined custom propertyAnders Kaseorg2022-09-191-1/+1
| | | | | | | | | Fixes gh-5105 Closes gh-5106 Signed-off-by: Anders Kaseorg <andersk@mit.edu> (cherry picked from commit ed306c0261ab63746040e5d58bb4477c3069a427)
* Deprecated: Improve $.trim performance for strings with lots of whitespaceVladimir Sitnikov2022-07-201-2/+4
| | | | | | | | | | Regex imp implementation takes `O(N^2)` time to trim the string when multiple adjacent spaces were present. The new expression require that the "whitespace run" starts from a non-whitespace to avoid `O(N^2)` behavior when the engine would try matching `\s+$` at each space position. Closes gh-5068
* CSS: Skip falsy values in `addClass( array )`, compress codeMichał Gołębiowski-Owczarek2022-01-251-36/+34
| | | | | | | | | | | | | | | | | | This change makes jQuery skip falsy values in `addClass( array )` & `removeClass( array )` instead of stopping iteration when the first falsy value is detected. This makes code like: ```js elem.addClass( [ "a", "", "b" ] ); ``` add both the `a` & `b` classes. The code was also optimized for size a bit so it doesn't increase the minified gzipped size. Fixes gh-4998 Closes gh-5003 (partially cherry picked from commit a338b407f2479f82df40635055effc163835183f)
* Docs: Replace `#NUMBER` Trac issue references with `trac-NUMBER`Michał Gołębiowski-Owczarek2022-01-1226-46/+46
| | | | | | | | | | | | | | | | | This is a version of gh-4993 for the `3.x-stable` branch. The GitHub UI treats `#NUMBER` as referring to its own issues which is confusing when in jQuery source it's usually referring to the old deprecated Trac instance at https://bugs.jquery.com. This change replaces all such Trac references with `trac-NUMBER`. A few of the references came with the Sizzle integration and referred to the Sizzle GitHub bug tracker. Those have been replaced with full links instead. A new entry describing issue reference conventions has been added to README. Closes gh-4994 Ref gh-4993 Ref 5d5ea015114092c157311c4948f7cc3d8c8e7f8a
* Docs: Remove links to Web Archive from sourceMichał Gołębiowski-Owczarek2022-01-042-2/+0
| | | | | | | | | | | Neither of the removed links is crucial; one of them refers to a site that has since started being malicious; while the Web Archive links remain safe, some scanners warn about such links. Removing them is the safest thing to do. Fixes gh-4981 Closes gh-4991 (cherry picked from commit e24f2dcf3f6bda1a672502e0233c732065cbbe89)
* CSS: Justify use of rtrim on CSS property valuesRichard Gibson2022-01-031-0/+6
| | | | | | | | | | CSS does not acknowledge carriage return or form feed characters as whitespace but it does replace them with whitespace, making it acceptable to use `rtrim`. Closes gh-4956 (cherry picked from commit 655c0ed5e204b1f6427e09d615a49586a7bc84eb)
* CSS: Remove a redundant extension from rtrimCSS inclusion in curCSSMichał Gołębiowski-Owczarek2021-10-191-1/+1
| | | | This breaks the AMD mode.
* CSS: Trim whitespace surrounding CSS Custom Properties valuesfecore12021-10-185-4/+41
| | | | | | | | | | | The spec has recently changed and CSS Custom Properties values are trimmed now. This change makes jQuery polyfill that new behavior for all browsers. Ref w3c/csswg-drafts#774 Fixes gh-4926 Closes gh-4930 (partially cherry picked from commit efadfe991a5c287af561a9326bf1427d726c91c1)
* Manipulation: Don't remove HTML comments from scriptsMichał Gołębiowski-Owczarek2021-07-191-1/+8
| | | | | | | | | | | | | | | | | | | | | When evaluating scripts, jQuery strips out the possible wrapping HTML comment and a CDATA section. However, all supported browsers are already doing that when loading JS via appending a script tag to the DOM which is how we've been doing `jQuery.globalEval` since jQuery 3.0.0. jQuery logic was imperfect, e.g. it just stripped the `<!--` and `-->` markers, respectively at the beginning or the end of the script contents. However, browsers are also stripping everything following those markers in the same line, treating them as single-line comments delimiters; this is now also mandated by ECMAScript 2015 in Annex B. Instead of fixing the jQuery logic, just let the browser do its thing. We still need to strip CDATA sections for backwards compatibility. This shouldn't be needed as in XML documents they're already not visible when inspecting element contents and in HTML documents they have no meaning but we're preserving that logic for backwards compatibility. This will be removed completely in 4.0. Fixes gh-4904 Closes gh-4905 Ref gh-4906
* Event: Don't break focus triggering after `.on(focus).off(focus)`Michał Gołębiowski-Owczarek2021-05-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | The `_default` function in the special event settings for focus/blur has always returned `true` since gh-4813 as the event was already being fired from `leverageNative`. However, that only works if there's an active handler on that element; this made a quick consecutive call: ```js elem.on( "focus", function() {} ).off( "focus" ); ``` make subsequent `.trigger( "focus" )` calls to not do any triggering. The solution, already used in a similar `_default` method for the `click` event, is to check for the `dataPriv` entry on the element for the focus event (similarly for blur). Fixes gh-4867 Closes gh-4885 (cherry picked from commit e539bac79e666bba95bba86d690b4e609dca2286)
* Support: ensure display is set to block for the support div (#4844)Timmy Willison2021-02-161-0/+8
| | | | | | - Fixes an issue with the support test in iframes in Android 8 Chrome 86+, where display: inline resulted in unexpected height values. Fixes gh-4832
* Deferred: Rename master to primaryMichał Gołębiowski-Owczarek2021-01-121-8/+8
| | | | | | Closes gh-4828 (cherry picked from a32cf6324f8f2190e66a687e94be9687ebf840b7)
* Dimensions: Modify reliableTrDimensions support test to account for FFTimmy Willison2021-01-111-2/+13
| | | | | | | | | Firefox incorrectly (or perhaps correctly) includes table borders in computed dimensions, but they are the only one. Workaround this by testing for it and falling back to offset properties Fixes gh-4529 Closes gh-4807
* Core: Report browser errors in parseXMLMichał Gołębiowski-Owczarek2020-12-081-6/+11
| | | | | | | Fixes gh-4784 Closes gh-4816 (cherry picked from commit 8969732518470a7f8e654d5bc5be0b0076cb0b87)
* Event: Make focus re-triggering not focus the original element backMichał Gołębiowski-Owczarek2020-12-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If during a focus handler another focus event is triggered: ```js elem1.on( "focus", function() { elem2.trigger( "focus" ); } ); ``` due to their synchronous nature everywhere outside of IE the hack added in gh-4279 to leverage native events causes the native `.focus()` method to be called last for the initial element, making it steal the focus back. Since the native method is already being called in `leverageNative`, we can skip that final call. This aligns with changes to the `_default` method for the `click` event that were added when `leverageNative` was introduced there. A side effect of this change is that now `focusin` will only propagate to the document for the last focused element. This is a change in behavior but it also aligns us better with how this works with native methods. Fixes gh-4382 Closes gh-4813 Ref gh-4279 (cherry picked from commit dbcffb396c2db61ff96edc4162602e850797d61f)
* Event: Don't crash if an element is removed on blurMichał Gołębiowski-Owczarek2020-10-191-1/+7
| | | | | | | | | | | | | In Chrome, if an element having a `focusout` handler is blurred by clicking outside of it, it invokes the handler synchronously. If that handler calls `.remove()` on the element, the data is cleared, leaving private data undefined. We're reading a property from that data so we need to guard against this. Fixes gh-4417 Closes gh-4799 (cherry picked from commit 5c2d08704e289dd2745bcb0557b35a9c0e6af4a4)
* Event: Remove the event.which shimMichał Gołębiowski-Owczarek2020-08-261-32/+2
| | | | | | | | | | | All supported browsers implement this property by themselves. The shim was only needed for IE <9. Fixes gh-3235 Closes gh-4765 Ref gh-4755 (cherry picked from commit 1a5fff4c169dbaa2df72c656868bcf60ed4413d0)
* Ajax: Execute JSONP error script responsesDallas Fraser2020-08-251-2/+4
| | | | | | | | | | | | | | | Issue gh-4379 was meant to be a bug fix but the JSONP case is a bit special: under the hood it's a script but it simulates JSON responses in an environment without a CORS setup and sending JSON payloads on error responses is quite typical there. This commit makes JSONP error responses still execute the payload. The regular script error responses continue to be skipped. Fixes gh-4771 Closes gh-4773 (cherry picked from commit a1e619b03a557b47c3e26a5e74af12b63a0d5e73)
* Core: Bring back QtWebKit support for jQuery 3.xNatalia Sroka2020-07-271-1/+5
| | | | | | | Allow jQuery to recognize that DOM types such as HTMLCollection or NodeList are not functions. Fixes gh-4756 Closes gh-4757
* Revert "Offset: Send px-ed strings to .css()"Michał Gołębiowski-Owczarek2020-07-201-6/+0
| | | | | | | | | | | | The way warning against number values in `.css()` setters was done in jquery/jquery-migrate#337 and later refined in jquery/jquery-migrate#348 there's no need to send px-ed strings for `top` & `left` as they already don't get the "px" suffix. This reverts commit 57038faebc6ece5bd666c28303f8a91ff59153eb. Closes gh-4753 Ref jquery/jquery-migrate/pull/337 Ref jquery/jquery-migrate/pull/348
* Build: Update eslint-config-jquery, fix linting violationsMichał Gołębiowski-Owczarek2020-05-181-1/+1
| | | | | | | | Closes gh-4696 Ref jquery/eslint-config-jquery#15 Ref jquery/eslint-config-jquery#16 (cherry picked from commit ef4d6ca6c3a1b276fedc27b1f3a18823276f01a3)
* Docs: Change JS Foundation mentions to OpenJS FoundationMichał Gołębiowski-Owczarek2020-05-181-1/+1
| | | | | | Closes gh-4711 (cherry picked from 11611967adf2bd9ff4304132f917629ec1134049)
* Build: Correct code indentations based on jQuery Style GuideWonseop Kim2020-05-0516-44/+70
| | | | | | | | | | | 1. Correct code indentations based on jQuery Style Guide (contribute.jquery.org/style-guide/js/#spacing). 2. Add rules to "src/.eslintrc.json" to enable "enforcing consistent indentation", with minimal changes to the current code. Closes gh-4672 (cherry picked from 3d62d5704989f17d3a20ae7521d52e9c8c60b4ee)
* Data: Make the data object a regular object againMichał Gołębiowski-Owczarek2020-04-201-1/+1
| | | | | | | | | | | | | The change in gh-4603 made the object returned by `elem.data()` a prototype-less object. That's a desired change to support keys colliding with `Object.prototype` properties but it's also a breaking change so it has to wait for jQuery 4.0.0. A 3.x-only test was added to avoid breaking it in the future on this branch. Fixes gh-4665 Ref gh-4603 Closes gh-4666
* Ajax: Do not execute scripts for unsuccessful HTTP responsesSean Robinson2020-04-061-0/+5
| | | | | | | | | | | | The script transport used to evaluate fetched script sources which is undesirable for unsuccessful HTTP responses. This is different to other data types where such a convention was fine (e.g. in case of JSON). (cherry picked from 50871a5a85cc802421b40cc67e2830601968affe) Fixes gh-4250 Fixes gh-4655 Closes gh-4379
* Ajax: Overwrite s.contentType with content-type header value, if anyChristian Wenz2020-04-061-0/+9
| | | | | | | | | | | | | | This fixes the issue of "%20" in POST data being replaced with "+" even for requests with content-type different from "application/x-www-form-urlencoded", e.g. for "application/json". Fixes gh-4119 Closes gh-4650 (cherry picked from 7fb90a6beaeffe16699800f73746748f6a5cc2de) Co-authored-by: Richard Gibson <richard.gibson@gmail.com> Co-authored-by: Michał Gołębiowski-Owczarek <m.goleb@gmail.com>
* Event: Use only one focusin/out handler per matching window & documentMichał Gołębiowski-Owczarek2020-04-061-2/+5
| | | | | | | | | | | | | | | The `doc` variable in: https://github.com/jquery/jquery/blob/3.4.1/src/event/focusin.js#L30 matched `document` for `document` & `window` for `window`, creating two separate wrapper event handlers & calling handlers twice if at least one `focusout` or `focusin` handler was attached on *both* `window` & `document`, or on `window` & another regular node. Also, fix the "focusin from an iframe" test to actually verify the behavior from commit 1cecf64e5aa415367a7dae0b55c2dd17b591442d - the commit that introduced the regression - to make sure we don't regress on either front. Fixes gh-4652 Closes gh-4656
* Manipulation: Skip the select wrapper for <option> outside of IE 9Michał Gołębiowski-Owczarek2020-03-302-7/+14
| | | Closes gh-4647
* Manipulation: Make jQuery.htmlPrefilter an identity functionMichał Gołębiowski-Owczarek2020-03-161-8/+1
| | | | | | Closes gh-4642 (cherry picked from 90fed4b453a5becdb7f173d9e3c1492390a1441f)
* Data:Event:Manipulation: Prevent collisions with Object.prototypeMichał Gołębiowski-Owczarek2020-03-024-9/+11
| | | | | | | | | | Make sure events & data keys matching Object.prototype properties work. A separate fix for such events on cloned elements was added as well. Fixes gh-3256 Closes gh-4603 (cherry picked from commit 9d76c0b163675505d1a901e5fe5249a2c55609bc)
* Build: Enable ESLint one-var rule for var declarations in browser codeMichał Gołębiowski-Owczarek2020-03-022-5/+6
| | | | | | | | | | Node.js code is written more & more commonly in ES6+ so it doesn't make sense to enable it there. There are many violations in test code so it's disabled there as well. Closes gh-4615 (cherry picked from commit 4a7fc8544e2020c75047456d11979e4e3a517fdf)
* Core:Ajax: Align nonce & global with master, fix an AMD issueMichał Gołębiowski-Owczarek2020-02-244-5/+6
| | | | | | | | | | | | | | | | This commit aligns the `3.x-stable` branch with `master` in two aspects: 1. It migrates the nonce module to return an object instead of a primitive variable. This had to be changed on `master` as in ES modules you export live read-only bindings to variables, meaning you can't increment the nonce directly. Also, the way it was done so far was working differently in AMD & the single built file - in the built file one nonce variable was declared, accessed and incremented. In AMD mode separate instances were create for each module that depend on the nonce module, creating unintended nonce clashes. 2. Whether the `noGlobal` parameter was set to `true` is now checked using the typeof operator to align with `master`. Closes gh-4612 Ref gh-4541 Ref d0ce00cdfa680f1f0c38460bc51ea14079ae8b07
* Core: Fire iframe script in its context, add doc param in globalEvalMichał Gołębiowski-Owczarek2020-02-103-6/+7
| | | | | | | | | | | | | 1. Support passing custom document to jQuery.globalEval; the script will be invoked in the context of this document. 2. Fire external scripts appended to iframe contents in that iframe context; this was already supported & tested for inline scripts but not for external ones. Fixes gh-4518 Closes gh-4601 (cherry picked from commit 4592595b478be979141ce35c693dbc6b65647173)
* Build:Tests: Fix custom build tests, verify on Travis; name Travis jobsMichał Gołębiowski-Owczarek2020-01-273-1/+3
| | | | | | | | | | | | | | | | This commit fixes unit tests for the following builds: 1. The no-deprecated build: `custom:-deprecated` 2. The current slim build: `custom:-ajax,-effects` 3. The 4.0 (#4553) slim build: `custom:-ajax,-callbacks,-deferred,-effects` It also adds separate Travis jobs for the no-deprecated & slim builds. Apart from that, add intuitive names to Travis jobs. Otherwise it's hard to see at a glance that a particular job is running on Firefox ESR, for example. Ref gh-4577 Ref gh-4596 Closes gh-4600
* Ajax: Deprecate AJAX event aliases, inline event/alias into deprecatedMichał Gołębiowski-Owczarek2020-01-215-53/+51
| | | | | | | | | | | A new `src/deprecated` directory makes it possible to exclude some deprecated APIs from a custom build when their respective "parent" module is excluded without keeping that module outside of the `src/deprecated` directory or the `src/deprecated.js` file. Closes gh-4572 (cherry picked from 23d53928f383b0e7440bf4b08b7524e6af232fad)
* Event: Only attach events to objects that accept data - for realMichał Gołębiowski-Owczarek2019-12-091-3/+4
| | | | | | | | | | | | | There was a check in jQuery.event.add that was supposed to make it a noop for objects that don't accept data like text or comment nodes. The problem was the check was incorrect: it assumed `dataPriv.get( elem )` returns a falsy value for an `elem` that doesn't accept data but that's not the case - we get an empty object then. The check was changed to use `acceptData` directly. (cherry picked from d5c505e35d8c74ce8e9d99731a1a7eab0e0d911c) Fixes gh-4397 Closes gh-4558
* Offset: Send px-ed strings to .css()Dave Methvin2019-10-211-0/+6
| | | | | An upcoming release of Migrate will generate warnings for calls to .css() that pass numbers rather than strings, see jquery/jquery-migrate#296 . At the moment, core's .offset() setter passes numbers rather than px strings so it would throw warnings. This commit fixes that. Closes gh-4508
* CSS: Workaround buggy getComputedStyle on table rows in IE/EdgeMichał Gołębiowski-Owczarek2019-10-142-10/+49
| | | | Fixes gh-4490 Closes gh-4503
* Build: ESLint: forbid unused function parametersMichał Gołębiowski-Owczarek2019-09-2614-23/+21
| | | | | | | | | | | | | | | | This commit requires all function parameters to be used, not just the last one. In cases where that's not possible as we need to match an external API, there's an escape hatch of prefixing an unused argument with `_`. This change makes it easier to catch unused AMD dependencies and unused parameters in internal functions the API of which we may change at will, among other things. Unused AMD dependencies have been removed as part of this commit. Closes gh-4381 (cherry-picked from 438b1a3e8a52d3e4efd8aba45498477038849c97)
* Effect: Fix a unnecessary conditional statement in .stop()Wonseop Kim2019-09-261-1/+1
| | | | | | | | | | | | Because of the above conditional, the 'type' variable has a value of type 'string' or undefined. Therefore, boolean comparisons for 'type' variable is always unnecessary because it return true. The patch removed the unnecessary conditional statement. Fixes gh-4374 Closes gh-4375 (cherry picked from commit 110802c7f22b677ef658963aa95ebdf5cb9c5573)
* Core: Deprecate jQuery.trimShashanka Nataraj2019-09-262-12/+10
| | | | | | | Fixes gh-4363 Closes gh-4461 (cherry picked from 5ea5946094784f68437ef26d463dfcfbbbaff1f6)
* Core: Use Array.prototype.flat where supportedAhmed.S.ElAfifi2019-09-254-14/+22
| | | | | | | | | | | | | Calling `Array.prototype.concat.apply( [], inputArray )` to flatten `inputArray` crashes for large arrays; using `Array.prototype.flat` avoids these issues in browsers that support it. In case it's necessary to support these large arrays even in older browsers, a polyfill for `Array.prototype.flat` can be loaded. This is already being done by many applications. (cherry picked from 9df4f1de12728b44a4b0f91748f12421008d9079) Fixes gh-4320 Closes gh-4459
* Core: Implement .even() & .odd() to replace POS :even & :oddMichał Gołębiowski-Owczarek2019-09-241-0/+12
| | | | | | | | | `:even` & `:odd` are deprecated since jQuery 3.4.0 & will be removed in 4.0.0. The new `even()` & `odd()` methods will make the migration easier. Closes gh-4485 (cherry picked from commit 78420d427cf3734d9264405fcbe08b76be182a95)
* Selector: Make selector-native's isXMLDoc recognize HTML-embedded SVGMichał Gołębiowski-Owczarek2019-07-291-5/+9
| | | | | | | | | | This commit also backports some jQuery.isXMLDoc tests from master so that this behavior doesn't regress. (partially cherry-picked from 79b74e043a4ee737d44a95094ff1184e40bd5b16) Closes gh-4438 Ref jquery/sizzle#378 Ref jquery/sizzle#436
* Traversing: Fix `contents()` on `<object>`s with children in IEMichał Gołębiowski-Owczarek2019-05-081-2/+9
| | | | | | | | | | | | The original fix didn't account for the fact that in IE `<object>` elements with no `data` attribute have an object `contentDocument`. The fix leverages the fact that this special object has a null prototype. (cherry-picked from ccbd6b93424cbdbf86f07a86c2e55cbab497d7a3) Closes gh-4390 Ref gh-4384 Ref gh-4385
* Traversing: Fix `contents()` on `<object>`s with childrenPat O'Callaghan2019-05-061-1/+1
| | | | | | | (cherry-picked from 4d865d96aa5aae91823c50020b5c19da79566811) Fixes gh-4384 Closes gh-4385
* Core: Make isAttached work with iOS 10.0-10.2Michał Gołębiowski-Owczarek2019-04-291-1/+5
| | | | | | | | | | | The test for Shadow DOM v1 support has been changed to rely on the presence of `documentElement.getRootNode` as iOS 10.0-10.2 supports `attachShadow` but doesn't support `getRootNode`. No new test is necessary - iOS 10.0 fails lots of our test suite because of this bug. Fixes gh-4356 Closes gh-4360
* Event: Prevent leverageNative from registering duplicate dummy handlersRichard Gibson2019-04-291-5/+5
| | | Closes gh-4353