Skip to content

Conversation

@Fil
Copy link
Contributor

@Fil Fil commented Oct 25, 2021

Se discussion in #579 (review)

src/style.js Outdated
}

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 <[email protected]>

Co-authored-by: Philippe Rivière <[email protected]>
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