Skip to content

Commit

Permalink
dependency: Update jquery to 3.4.1 (#29837)
Browse files Browse the repository at this point in the history
* Update jquery to 3.4.1

* refactor use of half scroll pixels with some explanation

* remove layer coords from tests + comment out non-working page& value in chromium

* Fix scrollTo calculation to match previous implementation

* add changelog entry

* patch jquery to use old calculations for width/height to avoid breaking change

* revert scrollTo changes since jquery height/width calc is patched

* Add issue to changelog

* Make it a dev patch since it's a dev dependency
  • Loading branch information
jennifer-shehane authored Jul 12, 2024
1 parent a901ea3 commit 17fd597
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 83 deletions.
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ _Released 7/16/2024 (PENDING)_

**Dependency Updates:**

- Updated `jquery` from `3.1.1` to `3.4.1`. Addresses [#29822](https://github.com/cypress-io/cypress/issues/29822). Addressed in [#29837](https://github.com/cypress-io/cypress/pull/29837).
- Updated `minimatch` from `3.0.4` to `3.1.2`. Addressed in [#29821](https://github.com/cypress-io/cypress/pull/29821).

## 13.13.0
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
"**/@types/cheerio": "0.22.21",
"**/@types/enzyme": "3.10.5",
"**/@types/react": "16.9.50",
"**/jquery": "3.1.1",
"**/jquery": "3.4.1",
"**/pretty-format": "26.4.0",
"**/sharp": "0.29.3",
"**/socket.io-parser": "4.0.5",
Expand Down
10 changes: 3 additions & 7 deletions packages/driver/cypress/e2e/commands/actions/click.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4103,10 +4103,10 @@ describe('mouse state', () => {
const coordsChrome = {
clientX: 492,
clientY: 9,
layerX: 492,
layerY: 215,
pageX: 492,
pageY: 215,
// pageY is 220.5 in headless Electron
// since updating to jquery 3.2+....why...
// pageY: 215,
screenX: 492,
screenY: 9,
x: 492,
Expand All @@ -4117,8 +4117,6 @@ describe('mouse state', () => {
const coordsFirefox = {
clientX: 494,
clientY: 10,
// layerX: 492,
// layerY: 215,
pageX: 494,
pageY: 226,
screenX: 494,
Expand All @@ -4130,8 +4128,6 @@ describe('mouse state', () => {
const coordsWebKit = {
clientX: 500,
clientY: 10,
layerX: 500,
layerY: 226,
pageX: 500,
pageY: 226,
screenX: 500,
Expand Down
26 changes: 15 additions & 11 deletions packages/driver/cypress/e2e/commands/actions/scroll.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ describe('src/cy/commands/actions/scroll', () => {

this.scrollBoth.scrollTop = 0
this.scrollBoth.scrollLeft = 0

// width/height of scrollable container - width of parent viewport (minux scrollbars) / 2 to get the center
// browsers round up the pixel value so we need to round it
this.halfScrollPixels = Math.round((500 - 100) / 2)
})

describe('subject', () => {
Expand Down Expand Up @@ -86,7 +90,7 @@ describe('src/cy/commands/actions/scroll', () => {
// in the percentage of the scroll (since going the height
// of the container wouldn't scroll at all...)
expect(this.scrollHoriz.get(0).scrollTop).to.eq(0)
expect(this.scrollHoriz.get(0).scrollLeft).to.eq((500 - 100) / 2)
expect(this.scrollHoriz.get(0).scrollLeft).to.eq(this.halfScrollPixels)
})
})
})
Expand All @@ -108,7 +112,7 @@ describe('src/cy/commands/actions/scroll', () => {

cy.get('#scroll-to-both').scrollTo('top').then(function () {
expect(this.scrollBoth.get(0).scrollTop).to.eq(0)
expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels)
})
})

Expand All @@ -127,7 +131,7 @@ describe('src/cy/commands/actions/scroll', () => {
expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)

cy.get('#scroll-to-both').scrollTo('left').then(function () {
expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels)
expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)
})
})
Expand All @@ -137,8 +141,8 @@ describe('src/cy/commands/actions/scroll', () => {
expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)

cy.get('#scroll-to-both').scrollTo('center').then(function () {
expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels)
expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels)
})
})

Expand All @@ -147,7 +151,7 @@ describe('src/cy/commands/actions/scroll', () => {
expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)

cy.get('#scroll-to-both').scrollTo('right').then(function () {
expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels)
expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100))
})
})
Expand All @@ -168,7 +172,7 @@ describe('src/cy/commands/actions/scroll', () => {

cy.get('#scroll-to-both').scrollTo('bottom').then(function () {
expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100))
expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels)
})
})

Expand Down Expand Up @@ -229,8 +233,8 @@ describe('src/cy/commands/actions/scroll', () => {
expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)

cy.get('#scroll-to-both').scrollTo('50%', '50%').then(function () {
expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels)
expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels)
})
})

Expand All @@ -239,7 +243,7 @@ describe('src/cy/commands/actions/scroll', () => {
expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)

cy.get('#scroll-to-both').scrollTo('0%', '50%').then(function () {
expect(this.scrollBoth.get(0).scrollTop).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollTop).to.eq(this.halfScrollPixels)
expect(this.scrollBoth.get(0).scrollLeft).to.eq(0)
})
})
Expand All @@ -250,7 +254,7 @@ describe('src/cy/commands/actions/scroll', () => {

cy.get('#scroll-to-both').scrollTo('50%', '0%').then(function () {
expect(this.scrollBoth.get(0).scrollTop).to.eq(0)
expect(this.scrollBoth.get(0).scrollLeft).to.eq((500 - 100) / 2)
expect(this.scrollBoth.get(0).scrollLeft).to.eq(this.halfScrollPixels)
})
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"is-valid-domain": "0.0.20",
"is-valid-hostname": "1.0.1",
"jimp": "0.22.12",
"jquery": "3.1.1",
"jquery": "3.4.1",
"js-cookie": "3.0.5",
"json-stable-stringify": "1.0.1",
"lodash": "^4.17.21",
Expand Down
223 changes: 223 additions & 0 deletions packages/driver/patches/jquery+3.4.1.dev.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
diff --git a/node_modules/jquery/README.md b/node_modules/jquery/README.md
deleted file mode 100644
index 411a859..0000000
--- a/node_modules/jquery/README.md
+++ /dev/null
@@ -1,67 +0,0 @@
-# jQuery
-
-> jQuery is a fast, small, and feature-rich JavaScript library.
-
-For information on how to get started and how to use jQuery, please see [jQuery's documentation](http://api.jquery.com/).
-For source files and issues, please visit the [jQuery repo](https://github.com/jquery/jquery).
-
-If upgrading, please see the [blog post for 3.4.1](https://blog.jquery.com/2019/05/01/jquery-3-4-1-triggering-focus-events-in-ie-and-finding-root-elements-in-ios-10/). This includes notable differences from the previous version and a more readable changelog.
-
-## Including jQuery
-
-Below are some of the most common ways to include jQuery.
-
-### Browser
-
-#### Script tag
-
-```html
-<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
-```
-
-#### Babel
-
-[Babel](http://babeljs.io/) is a next generation JavaScript compiler. One of the features is the ability to use ES6/ES2015 modules now, even though browsers do not yet support this feature natively.
-
-```js
-import $ from "jquery";
-```
-
-#### Browserify/Webpack
-
-There are several ways to use [Browserify](http://browserify.org/) and [Webpack](https://webpack.github.io/). For more information on using these tools, please refer to the corresponding project's documention. In the script, including jQuery will usually look like this...
-
-```js
-var $ = require("jquery");
-```
-
-#### AMD (Asynchronous Module Definition)
-
-AMD is a module format built for the browser. For more information, we recommend [require.js' documentation](http://requirejs.org/docs/whyamd.html).
-
-```js
-define(["jquery"], function($) {
-
-});
-```
-
-### Node
-
-To include jQuery in [Node](nodejs.org), first install with npm.
-
-```sh
-npm install jquery
-```
-
-For jQuery to work in Node, a window with a document is required. Since no such window exists natively in Node, one can be mocked by tools such as [jsdom](https://github.com/tmpvar/jsdom). This can be useful for testing purposes.
-
-```js
-require("jsdom").env("", function(err, window) {
- if (err) {
- console.error(err);
- return;
- }
-
- var $ = require("jquery")(window);
-});
-```
diff --git a/node_modules/jquery/dist/jquery.js b/node_modules/jquery/dist/jquery.js
index 773ad95..9e6076f 100644
--- a/node_modules/jquery/dist/jquery.js
+++ b/node_modules/jquery/dist/jquery.js
@@ -6534,69 +6534,100 @@ function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computed
return delta;
}

-function getWidthOrHeight( elem, dimension, extra ) {
+function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
+ var i,
+ val = 0;

- // Start with computed style
- var styles = getStyles( elem ),
+ // If we already have the right measurement, avoid augmentation
+ if ( extra === ( isBorderBox ? "border" : "content" ) ) {
+ i = 4;

- // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
- // Fake content-box until we know it's needed to know the true value.
- boxSizingNeeded = !support.boxSizingReliable() || extra,
- isBorderBox = boxSizingNeeded &&
- jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
- valueIsBorderBox = isBorderBox,
+ // Otherwise initialize for horizontal or vertical properties
+ } else {
+ i = name === "width" ? 1 : 0;
+ }

- val = curCSS( elem, dimension, styles ),
- offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
+ for ( ; i < 4; i += 2 ) {

- // Support: Firefox <=54
- // Return a confounding non-pixel value or feign ignorance, as appropriate.
- if ( rnumnonpx.test( val ) ) {
- if ( !extra ) {
- return val;
+ // Both box models exclude margin, so add it if we want it
+ if ( extra === "margin" ) {
+ val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
+ }
+
+ if ( isBorderBox ) {
+
+ // border-box includes padding, so remove it if we want content
+ if ( extra === "content" ) {
+ val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+ }
+
+ // At this point, extra isn't border nor margin, so remove border
+ if ( extra !== "margin" ) {
+ val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+ }
+ } else {
+
+ // At this point, extra isn't content, so add padding
+ val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+
+ // At this point, extra isn't content nor padding, so add border
+ if ( extra !== "padding" ) {
+ val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+ }
}
- val = "auto";
}

+ return val;
+}

- // Fall back to offsetWidth/offsetHeight when value is "auto"
- // This happens for inline elements with no explicit setting (gh-3571)
- // Support: Android <=4.1 - 4.3 only
- // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
- // Support: IE 9-11 only
- // Also use offsetWidth/offsetHeight for when box sizing is unreliable
- // We use getClientRects() to check for hidden/disconnected.
- // In those cases, the computed value can be trusted to be border-box
- if ( ( !support.boxSizingReliable() && isBorderBox ||
- val === "auto" ||
- !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
- elem.getClientRects().length ) {
+function getWidthOrHeight( elem, name, extra ) {

+ // Start with offset property, which is equivalent to the border-box value
+ var val,
+ valueIsBorderBox = true,
+ styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";

- // Where available, offsetWidth/offsetHeight approximate border box dimensions.
- // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
- // retrieved value as a content box dimension.
- valueIsBorderBox = offsetProp in elem;
- if ( valueIsBorderBox ) {
- val = elem[ offsetProp ];
- }
+ // Support: IE <=11 only
+ // Running getBoundingClientRect on a disconnected node
+ // in IE throws an error.
+ if ( elem.getClientRects().length ) {
+ val = elem.getBoundingClientRect()[ name ];
}

- // Normalize "" and auto
- val = parseFloat( val ) || 0;
+ // Some non-html elements return undefined for offsetWidth, so check for null/undefined
+ // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
+ // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
+ if ( val <= 0 || val == null ) {

- // Adjust for the element's box model
+ // Fall back to computed then uncomputed css if necessary
+ val = curCSS( elem, name, styles );
+ if ( val < 0 || val == null ) {
+ val = elem.style[ name ];
+ }
+
+ // Computed unit is not pixels. Stop here and return.
+ if ( rnumnonpx.test( val ) ) {
+ return val;
+ }
+
+ // Check for style in case a browser which returns unreliable values
+ // for getComputedStyle silently falls back to the reliable elem.style
+ valueIsBorderBox = isBorderBox &&
+ ( support.boxSizingReliable() || val === elem.style[ name ] );
+
+ // Normalize "", auto, and prepare for extra
+ val = parseFloat( val ) || 0;
+ }
+
+ // Use the active box-sizing model to add/subtract irrelevant styles
return ( val +
- boxModelAdjustment(
+ augmentWidthOrHeight(
elem,
- dimension,
+ name,
extra || ( isBorderBox ? "border" : "content" ),
valueIsBorderBox,
- styles,
-
- // Provide the current computed size to request scroll gutter calculation (gh-3589)
- val
+ styles
)
) + "px";
}
Loading

5 comments on commit 17fd597

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 17fd597 Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.1/linux-x64/develop-17fd5976d0994c135150ab2a597c3c0bed2648ed/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 17fd597 Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.1/linux-arm64/develop-17fd5976d0994c135150ab2a597c3c0bed2648ed/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 17fd597 Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.1/win32-x64/develop-17fd5976d0994c135150ab2a597c3c0bed2648ed/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 17fd597 Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.1/darwin-x64/develop-17fd5976d0994c135150ab2a597c3c0bed2648ed/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 17fd597 Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.13.1/darwin-arm64/develop-17fd5976d0994c135150ab2a597c3c0bed2648ed/cypress.tgz

Please sign in to comment.