Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: ensure position/offset return mutable objects #3695

Merged
merged 2 commits into from Jul 10, 2017

Conversation

jbedard
Copy link
Contributor

@jbedard jbedard commented Jun 15, 2017

This adds tests verifying #3612. Could probably add more but this seemed to cover most cases?

Could potentially also revert 3befe59

Copy link
Member

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

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

LGTM, and I'm also in favor of reverting 3befe59 unless doing so increases gzipped size.

@@ -75,10 +75,11 @@ QUnit.test( "disconnected element", function( assert ) {
assert.equal( result.top, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
assert.equal( result.left, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" );
assert.equal( Object.keys( result ).length, 2, "Retrieving offset on disconnected elements returns offset object (gh-3167)" );
assert.equal( jQuery.isPlainObject( result ), true, "Retrieving offset on disconnected elements returns plain object (gh-3612)" );
Copy link
Member

Choose a reason for hiding this comment

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

Should we be actually trying to mutate the object here? The jQuery.isPlainObject() test is a bit of an indirect feature test and technically we could be returning a plain object with read-only properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I was just ensuring it wasn't a ClientRect. I could create a helper that checks both isPlainObject and ensures it is modifiable. WDYT?

@timmywil
Copy link
Member

Agreed, revert 3befe59, and good to land.

@jbedard
Copy link
Contributor Author

jbedard commented Jun 28, 2017

Was there any discussion about the use of isPlainObject vs something more specific?

@jbedard
Copy link
Contributor Author

jbedard commented Jul 5, 2017

I've added the revert of 3befe59 since it reduces size:

   raw     gz Compared to master @ 31783e60f5649b194128a6e39404617c69117dab
   -28     -7 dist/jquery.js
     =      = dist/jquery.min.js

@jbedard jbedard merged commit 0fb6b9a into jquery:master Jul 10, 2017
jbedard added a commit that referenced this pull request Jul 10, 2017
left: parentOffset.left + jQuery.css( offsetParent, "borderLeftWidth", true )
};
parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
Copy link
Member

Choose a reason for hiding this comment

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

I think these need to be offsetParent, not offsetParent[ 0 ].

jbedard added a commit to jbedard/jquery that referenced this pull request Jul 10, 2017
jbedard added a commit that referenced this pull request Jul 10, 2017
ornicar added a commit to ornicar/jquery that referenced this pull request Jul 30, 2017
* 'master' of git://github.com/jquery/jquery: (92 commits)
  Ajax: add an ontimeout handler to all requests
  Tests: Account for TestSwarm focus issues
  Tests: Simulate events when CI hinders use of native ones
  Tests: Reduce the abort timeout for simple focus testing
  Tests: Abort focus tests when the environment doesn't cooperate
  Tests: Try extra hard to control focus
  Support: Properly check for IE9 absolute scrollbox mishandling
  Dimensions: Detect and account for content-box dimension mishandling
  Offset: fix error from bad merge in jquery#3695
  Revert "Offset: Resolve strict mode ClientRect "no setter" exception"
  Test: ensure position/offset return mutable objects
  Core: Deprecate jQuery.isWindow
  Event: `stopPropagation()` on native event-handler
  Build: fix uglify options for uglify update
  Build: Update sinon, husky, and qunitjs
  Build: update node dependencies; commit package-lock.json
  Deferred: fix memory leak of promise callbacks
  Dimensions: Include scroll gutter in "padding" box
  Tests: minor typos
  Build: Test on Node.js 8, stop testing on Node.js 7
  ...
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants