🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@jbedard
Copy link
Contributor

@jbedard jbedard commented Jun 11, 2018

Fixes gh-3964

Summary

Checklist

Copy link
Member

@timmywil timmywil left a comment

Choose a reason for hiding this comment

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

LGTM

src/css.js Outdated

// Account for positive content-box scroll gutter when requested by providing computedVal
if ( !isBorderBox && computedVal >= 0 ) {
var val = elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ];
Copy link
Member

Choose a reason for hiding this comment

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

The offsetWidth/offsetHeight comment seems misplaced now, doesn't it?

Also, a comment about why the fallback is needed (below, at line 138) would be useful, it's not clear now.

src/css.js Outdated

// Account for positive content-box scroll gutter when requested by providing computedVal
if ( !isBorderBox && computedVal >= 0 ) {
var val = elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ];
Copy link
Member

@gibson042 gibson042 Jun 11, 2018

Choose a reason for hiding this comment

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

I agree with @mgol on comment placement, and also observe that

  • defining a new variable here is against our general style, and
  • val is an overly generic name, and
  • it provides little benefit anyway, since delta will never be modified when offsetWidth/offsetHeight is unknown (computedVal - computedVal - delta - extra - 0.5 is guaranteed to be negative in this case, so Math.ceil will not be positive, so Math.max will be 0).

I think we should keep things simpler:

// offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
// Scroll gutter is that value minus the other properties, rounded half-down to the nearest integer
delta += Math.max( 0, Math.ceil(
	elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
	computedVal -
	delta -
	extra -
	0.5

// If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
// Use an explicit zero to avoid NaN (gh-3964)
) ) || 0;

@jbedard
Copy link
Contributor Author

jbedard commented Jun 12, 2018

Updated

@gibson042 I agree with everything you said. At one point the fix I had needed the var and I never really cleaned it up after. Thanks for pointing it out 👍

@jbedard jbedard merged commit e743cbd into jquery:master Jun 21, 2018
@sduquej
Copy link

sduquej commented Dec 5, 2018

👋 Hey folks, are there plans to release a patch version that includes this fix?

@mgol
Copy link
Member

mgol commented Dec 5, 2018

@sduquej It will be included in 3.4.0 which we'll hopefully release soon (but it's hard to predict exact timing).

@sduquej
Copy link

sduquej commented Dec 5, 2018

thanks Michał, appreciate the quick follow-up! Will keep an eye out as we're running into this issue in our app and decided to fall back to v3.2.1 as a workaround.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
@mgol mgol added this to the 3.4.0 milestone Jan 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

outerWidth of svg yields NaNpx. Previously yielded a number.

5 participants