Skip to content

Comments

Make line-numbers styles more specific#1434

Merged
mAAdhaTTah merged 1 commit intogh-pagesfrom
fix-line-numbers-specificity
Jun 3, 2018
Merged

Make line-numbers styles more specific#1434
mAAdhaTTah merged 1 commit intogh-pagesfrom
fix-line-numbers-specificity

Conversation

@mAAdhaTTah
Copy link
Member

The padding added to pre.line-numbers in the line-number's CSS is
overwritten by the theme's CSS if the theme is loaded second. This
ensures the CSS can come in any order without specificity issues.

I ran into this problem in the settings page for WP-Gistpen, where the
user can toggle the theme and enabled plugins. Switching between themes
removes the CSS for the previous theme from the head and injects the new
theme into the head, so the line-numbers CSS actually appears in the
head first. The theme CSS that sets the padding uses pre while the
line-numbers pre.line-numbers, and who "wins" is whomever
comes second.

There's also some whitespace cleanup here as well.

I think this is unlikely to be a breaking change, but interested in feedback on this.

The padding added to `pre.line-numbers` in the line-number's CSS is
overwritten by the theme's CSS if the theme is loaded second. This
ensures the CSS can come in any order without specificity issues.
@mAAdhaTTah mAAdhaTTah added the bug label Jun 1, 2018
@Golmote
Copy link
Contributor

Golmote commented Jun 3, 2018

Wow, good catch. It does not happen on the website because we switch the theme "in place" so the order is kept. Looks good to me!

@mAAdhaTTah mAAdhaTTah merged commit 03e8d9c into gh-pages Jun 3, 2018
@mAAdhaTTah mAAdhaTTah deleted the fix-line-numbers-specificity branch June 3, 2018 14:02
@mAAdhaTTah
Copy link
Member Author

So this introduces a bug in the Coy theme unless the CSS is loaded in reverse, because Coy moves the padding to the code element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants