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

Use inline style value, if present. #120

Merged
merged 1 commit into from
May 15, 2017
Merged

Use inline style value, if present. #120

merged 1 commit into from
May 15, 2017

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Mar 8, 2017

Rather than always returning the computed style value, selection.style now favors the inline value if present, and only falls back to the computed value if an inline value is not present.

By not computing the style value in the common case where an inline style is present, this is faster, but more importantly it is more predictable, since a computed value can be surprisingly different from an inline value, such as when the inline value is specified as a percentage.

This change is especially useful for transition.style, d3/d3-transition#47, so that you can control the starting style value of a transition.

Rather than always returning the computed style value, selection.style now
favors the inline value, if present, and only falls back to the computed value
if an inline value is not present.

By not computing the style value in the common case where an inline style is
present, this is faster, but more importantly it is more predictable, since a
computed value can be surprisingly different from an inline value, such as when
the inline value is specified as a percentage.

This change is especially useful for transition.style, d3/d3-transition#47, so
that you can control the starting style value of a transition.
mbostock added a commit to d3/d3-transition that referenced this pull request Mar 8, 2017
Rather than always starting from the computed style value, transition.style now
favors the inline value, if present, and only falls back to the computed value
if an inline value is not present.

By not computing the style value in the common case where an inline style is
present, this is faster, but more importantly it is more predictable since a
computed value can be surprisingly different from an inline value, such as when
the inline value is specified as a percentage.

Related d3/d3-selection#120. Fixes #47.
@mbostock mbostock self-assigned this May 5, 2017
@mbostock mbostock merged commit e7c72a6 into master May 15, 2017
@mbostock mbostock deleted the style-value branch May 15, 2017 17:36
mbostock added a commit to d3/d3-transition that referenced this pull request May 15, 2017
Rather than always starting from the computed style value, transition.style now
favors the inline value, if present, and only falls back to the computed value
if an inline value is not present.

By not computing the style value in the common case where an inline style is
present, this is faster, but more importantly it is more predictable since a
computed value can be surprisingly different from an inline value, such as when
the inline value is specified as a percentage.

Related d3/d3-selection#120. Fixes #47.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant