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

[BUGFIX beta] assert that classNameBinding items are strings #15924

Merged
merged 1 commit into from
Dec 7, 2017
Merged

[BUGFIX beta] assert that classNameBinding items are strings #15924

merged 1 commit into from
Dec 7, 2017

Conversation

GavinJoyce
Copy link
Member

@GavinJoyce GavinJoyce commented Dec 5, 2017

fixes #15851

(this was part of an Ember open source workshop in Intercom)

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

Minor stylistic nit-picks, but overall looks good to me.

@@ -412,6 +412,18 @@ export function validatePositionalParameters(named: NamedArguments, positional:
}

export function processComponentInitializationAssertions(component: Component, props: any) {
assert(`classNameBindings must be strings: ${component.toString()}`, (() => {
Copy link
Member

Choose a reason for hiding this comment

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

Seems fine, but I would have assumed that the explicit .toString() shouldn't have been needed inside template strings. Mind confirming?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, that's the case. I've updated the other similar tests to remove toString and use template strings too

for (let i = 0; i < classNameBindings.length; i++) {
let binding = classNameBindings[i];

if (typeof(binding) !== '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 think we generally prefer typeof binding !== 'string'

@GavinJoyce
Copy link
Member Author

GavinJoyce commented Dec 7, 2017

@rwjblue thanks for the feedback, the PR has been updated and is ready for review again

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

You rock, thank you!!

@rwjblue rwjblue merged commit a8c0232 into emberjs:master Dec 7, 2017
@GavinJoyce GavinJoyce deleted the gj/class-name-bindings-string-assertion branch December 7, 2017 12:29
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.

classNameBindings with ,, compiles but causes runtime problems
2 participants