Skip to content

top-level className #582

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

Merged
merged 4 commits into from
Oct 26, 2021
Merged

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Oct 25, 2021

Se discussion in #579 (review)

src/style.js Outdated
@@ -153,3 +153,8 @@ export function filterStyles(index, {fill: F, fillOpacity: FO, stroke: S, stroke
function none(color) {
return color == null || color === "none";
}

export function validClassName(str) {
return typeof str === "string" &&
Copy link
Member

Choose a reason for hiding this comment

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

I would expect string coercion here instead of requiring the string type exactly.

I’m curious why we’re validating the class name? Is it just to avoid people using it to inject arbitrary styles into our style sheet? That seems reasonable if so.

Copy link
Contributor Author

@Fil Fil Oct 25, 2021

Choose a reason for hiding this comment

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

Yes, I mainly wanted to avoid multiple classes (space-separated), which would break things. Then realized we didn't want curly brackets for the reason you're saying. Validating against the spec seemed like a good idea to avoid any shenanigans—maybe overkill tho. We can remove type check.

Base automatically changed from fil/inline-styles-test to mbostock/inline-styles October 26, 2021 02:09
@mbostock mbostock merged commit 84bc745 into mbostock/inline-styles Oct 26, 2021
@mbostock mbostock deleted the fil/top-level-className branch October 26, 2021 02:16
mbostock added a commit that referenced this pull request Oct 26, 2021
* inline styles; tabular nums

* inline styles test (#581)

* keep inline stylesheet

* inline stylesheets

* top-level className (#582)

* keep inline stylesheet

* inline stylesheets

* top-level className

* coerce className to string

Co-authored-by: Mike Bostock <mbostock@gmail.com>

Co-authored-by: Philippe Rivière <fil@rezo.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants